mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Fix warnings
This change fixes Cosmopolitan so it has fewer opinions about compiler warnings. The whole repository had to be cleaned up to be buildable in -Werror -Wall mode. This lets us benefit from things like strict const checking. Some actual bugs might have been caught too.
This commit is contained in:
parent
e2b3c3618e
commit
0d748ad58e
571 changed files with 1306 additions and 1888 deletions
6
third_party/python/Python/ceval.c
vendored
6
third_party/python/Python/ceval.c
vendored
|
@ -5353,6 +5353,9 @@ dtrace_function_entry(PyFrameObject *f)
|
|||
char* filename;
|
||||
char* funcname;
|
||||
int lineno;
|
||||
(void)filename;
|
||||
(void)funcname;
|
||||
(void)lineno;
|
||||
filename = PyUnicode_AsUTF8(f->f_code->co_filename);
|
||||
funcname = PyUnicode_AsUTF8(f->f_code->co_name);
|
||||
lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
|
||||
|
@ -5365,6 +5368,9 @@ dtrace_function_return(PyFrameObject *f)
|
|||
char* filename;
|
||||
char* funcname;
|
||||
int lineno;
|
||||
(void)filename;
|
||||
(void)funcname;
|
||||
(void)lineno;
|
||||
filename = PyUnicode_AsUTF8(f->f_code->co_filename);
|
||||
funcname = PyUnicode_AsUTF8(f->f_code->co_name);
|
||||
lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
|
||||
|
|
9
third_party/python/Python/cosmomodule.c
vendored
9
third_party/python/Python/cosmomodule.c
vendored
|
@ -100,13 +100,13 @@ cosmo_rdtsc(PyObject *self, PyObject *noargs)
|
|||
return PyLong_FromUnsignedLong(rdtsc());
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
PyDoc_STRVAR(getcpucore_doc,
|
||||
"getcpucore($module)\n\
|
||||
--\n\n\
|
||||
Returns 0-indexed CPU core on which process is currently scheduled.");
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
static PyObject *
|
||||
cosmo_getcpucore(PyObject *self, PyObject *noargs)
|
||||
{
|
||||
|
@ -137,7 +137,6 @@ Similar to zlib.crc32().");
|
|||
static PyObject *
|
||||
cosmo_crc32c(PyObject *self, PyObject *args)
|
||||
{
|
||||
Py_ssize_t n;
|
||||
Py_buffer data;
|
||||
unsigned crc, init = 0;
|
||||
if (!PyArg_ParseTuple(args, "y*|I:crc32c", &data, &init)) return 0;
|
||||
|
@ -283,8 +282,6 @@ cosmo_exit1(PyObject *self, PyObject *args)
|
|||
_Exit(1);
|
||||
}
|
||||
|
||||
static bool ftrace_installed = 0;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
} FtracerObject;
|
||||
|
@ -327,6 +324,7 @@ static PyTypeObject FtracerType = {
|
|||
.tp_methods = FtracerObject_methods,
|
||||
};
|
||||
|
||||
#ifdef FTRACE
|
||||
PyDoc_STRVAR(ftrace_doc,
|
||||
"ftrace($module)\n\
|
||||
--\n\n\
|
||||
|
@ -337,6 +335,7 @@ Enables logging of C function calls to stderr, e.g.\n\
|
|||
\n\
|
||||
Please be warned this prints massive amount of text. In order for it\n\
|
||||
to work, the concomitant .com.dbg binary needs to be present.");
|
||||
#endif
|
||||
|
||||
static PyObject *
|
||||
cosmo_ftrace(PyObject *self, PyObject *noargs)
|
||||
|
|
1
third_party/python/Python/fatality.c
vendored
1
third_party/python/Python/fatality.c
vendored
|
@ -17,7 +17,6 @@
|
|||
/* clang-format off */
|
||||
|
||||
_Py_IDENTIFIER(flush);
|
||||
_Py_IDENTIFIER(stdout);
|
||||
_Py_IDENTIFIER(stderr);
|
||||
|
||||
/* Import the site module (not into __main__ though) */
|
||||
|
|
5
third_party/python/Python/import.c
vendored
5
third_party/python/Python/import.c
vendored
|
@ -865,7 +865,7 @@ PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co,
|
|||
{
|
||||
struct stat stinfo;
|
||||
PyObject *m = NULL;
|
||||
PyObject *nameobj, *pathobj = NULL, *cpathobj = NULL, *external= NULL;
|
||||
PyObject *nameobj, *pathobj = NULL, *cpathobj = NULL;
|
||||
|
||||
nameobj = PyUnicode_FromString(name);
|
||||
if (nameobj == NULL)
|
||||
|
@ -1183,7 +1183,7 @@ _imp_create_builtin(PyObject *module, PyObject *spec)
|
|||
res = bsearch(&key, Builtins_Lookup.entries, Builtins_Lookup.n, sizeof(initentry), cmp_initentry);
|
||||
|
||||
if (res != NULL) {
|
||||
p = res->tab;
|
||||
p = (void *)res->tab;
|
||||
PyModuleDef *def;
|
||||
if (p->initfunc == NULL) {
|
||||
/* Cannot re-init internal module ("sys" or "builtins") */
|
||||
|
@ -2491,7 +2491,6 @@ static PyObject *SFLObject_get_code(SourcelessFileLoader *self, PyObject *arg) {
|
|||
FILE *fp = NULL;
|
||||
PyObject *res = NULL;
|
||||
char *rawbuf = NULL;
|
||||
size_t rawlen = 0;
|
||||
|
||||
if (!PyArg_Parse(arg, "z:get_code", &name)) return 0;
|
||||
if (!name) name = self->name;
|
||||
|
|
1
third_party/python/Python/initimport.c
vendored
1
third_party/python/Python/initimport.c
vendored
|
@ -30,7 +30,6 @@ _Py_InitImport(PyInterpreterState *interp, PyObject *sysmod)
|
|||
{
|
||||
PyObject *importlib;
|
||||
PyObject *impmod;
|
||||
PyObject *cosmomod;
|
||||
PyObject *sys_modules;
|
||||
PyObject *value;
|
||||
|
||||
|
|
7
third_party/python/Python/pylifecycle.c
vendored
7
third_party/python/Python/pylifecycle.c
vendored
|
@ -4,6 +4,7 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Include/pylifecycle.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
|
@ -13,8 +14,8 @@
|
|||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/str/locale.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/ast.h"
|
||||
|
@ -37,7 +38,6 @@
|
|||
#include "third_party/python/Include/parsetok.h"
|
||||
#include "third_party/python/Include/pydebug.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/pylifecycle.h"
|
||||
#include "third_party/python/Include/pymem.h"
|
||||
#include "third_party/python/Include/pystrcmp.h"
|
||||
#include "third_party/python/Include/pytime.h"
|
||||
|
@ -53,9 +53,6 @@
|
|||
|
||||
/* Python interpreter top-level routines, including init/exit */
|
||||
|
||||
_Py_IDENTIFIER(name);
|
||||
_Py_IDENTIFIER(flush);
|
||||
_Py_IDENTIFIER(stdout);
|
||||
_Py_IDENTIFIER(stderr);
|
||||
|
||||
/* Forward */
|
||||
|
|
5
third_party/python/Python/random.c
vendored
5
third_party/python/Python/random.c
vendored
|
@ -11,8 +11,8 @@
|
|||
#include "libc/fmt/conv.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
#include "libc/sysv/consts/grnd.h"
|
||||
|
@ -392,7 +392,6 @@ void
|
|||
_PyRandom_Init(void)
|
||||
{
|
||||
char *env;
|
||||
const unsigned char *auxrng;
|
||||
unsigned char *secret = (unsigned char *)&_Py_HashSecret.uc;
|
||||
Py_ssize_t secret_size = sizeof(_Py_HashSecret_t);
|
||||
Py_BUILD_ASSERT(sizeof(_Py_HashSecret_t) == sizeof(_Py_HashSecret.uc));
|
||||
|
@ -431,7 +430,7 @@ _PyRandom_Init(void)
|
|||
}
|
||||
else {
|
||||
uint64_t x;
|
||||
int res, i, j;
|
||||
int i, j;
|
||||
/* _PyRandom_Init() is called very early in the Python initialization
|
||||
and so exceptions cannot be used (use raise=0).
|
||||
_PyRandom_Init() must not block Python initialization: call
|
||||
|
|
35
third_party/python/Python/sysmodule.c
vendored
35
third_party/python/Python/sysmodule.c
vendored
|
@ -1026,11 +1026,6 @@ sys_getwindowsversion(PyObject *self)
|
|||
int pos = 0;
|
||||
PyObject *version;
|
||||
struct NtOsVersionInfo ver;
|
||||
uint32_t realMajor, realMinor, realBuild;
|
||||
int64_t hKernel32;
|
||||
wchar_t kernel32_path[PATH_MAX];
|
||||
void *verblock;
|
||||
uint32_t verblock_size;
|
||||
|
||||
if (!IsWindows()) {
|
||||
PyErr_SetString(PyExc_SystemError, "this is not windows");
|
||||
|
@ -1055,36 +1050,6 @@ sys_getwindowsversion(PyObject *self)
|
|||
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wSuiteMask));
|
||||
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wProductType));
|
||||
|
||||
realMajor = ver.dwMajorVersion;
|
||||
realMinor = ver.dwMinorVersion;
|
||||
realBuild = ver.dwBuildNumber;
|
||||
|
||||
#if 0 // todo(jart): port me
|
||||
// GetVersion will lie if we are running in a compatibility mode.
|
||||
// We need to read the version info from a system file resource
|
||||
// to accurately identify the OS version. If we fail for any reason,
|
||||
// just return whatever GetVersion said.
|
||||
hKernel32 = GetModuleHandle("kernel32.dll");
|
||||
if (hKernel32 && GetModuleFileNameW(hKernel32, kernel32_path, MAX_PATH) &&
|
||||
(verblock_size = GetFileVersionInfoSizeW(kernel32_path, NULL)) &&
|
||||
(verblock = PyMem_RawMalloc(verblock_size))) {
|
||||
VS_FIXEDFILEINFO *ffi;
|
||||
UINT ffi_len;
|
||||
if (GetFileVersionInfoW(kernel32_path, 0, verblock_size, verblock) &&
|
||||
VerQueryValueW(verblock, L"", (LPVOID)&ffi, &ffi_len)) {
|
||||
realMajor = HIWORD(ffi->dwProductVersionMS);
|
||||
realMinor = LOWORD(ffi->dwProductVersionMS);
|
||||
realBuild = HIWORD(ffi->dwProductVersionLS);
|
||||
}
|
||||
PyMem_RawFree(verblock);
|
||||
}
|
||||
PyStructSequence_SET_ITEM(version, pos++, Py_BuildValue("(kkk)",
|
||||
realMajor,
|
||||
realMinor,
|
||||
realBuild
|
||||
));
|
||||
#endif
|
||||
|
||||
if (PyErr_Occurred()) {
|
||||
Py_DECREF(version);
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue