]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix Windows build warnings (#131487)
authorVictor Stinner <vstinner@python.org>
Thu, 20 Mar 2025 11:03:20 +0000 (12:03 +0100)
committerGitHub <noreply@github.com>
Thu, 20 Mar 2025 11:03:20 +0000 (12:03 +0100)
Fix the following warnings:

* Modules\_io\fileio.c(1296,13): unused variable 'self'
* Modules\_io\winconsoleio.c(334,9): unused variable 'fd_is_own'
* Modules\faulthandler.c(409,11): unused variable 'flags'
* Modules\posixmodule.c(5699,9): unused variable 'pathError'
* PC\winreg.c(2077,5): suggest braces around initialization of
  subobject
* PC\winreg.c(34,13): unused variable 'errNotAHandle'
* Python\fileutils.c(132,12): result of comparison of constant
  1114111 with expression of type 'wchar_t' (aka 'unsigned short') is
  always false
* Python\fileutils.c(58,21): unused variable 'INCOMPLETE_CHARACTER'
* Python\sysmodule.c(2534,21): unused variable 'perf_map_state'

Modules/_io/fileio.c
Modules/_io/winconsoleio.c
Modules/faulthandler.c
Modules/posixmodule.c
PC/winreg.c
Python/fileutils.c
Python/sysmodule.c

index 54e5270f8161d62dfc15ce84c24e82dc1a5d61b6..0c5424954be1f741c31b46cf93f65082c031638d 100644 (file)
@@ -1293,8 +1293,8 @@ fileio_get_mode(PyObject *op, void *closure)
 static PyObject *
 fileio_get_blksize(PyObject *op, void *closure)
 {
-    fileio *self = PyFileIO_CAST(op);
 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
+    fileio *self = PyFileIO_CAST(op);
     if (self->stat_atopen != NULL && self->stat_atopen->st_blksize > 1) {
         return PyLong_FromLong(self->stat_atopen->st_blksize);
     }
index 3f137fa1f5412587d7dabb6eaec1fe69d427fb6a..77fe5259e4af1e509aae00721bb1494c1bc66074 100644 (file)
@@ -331,7 +331,6 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
     int ret = 0;
     int rwa = 0;
     int fd = -1;
-    int fd_is_own = 0;
     HANDLE handle = NULL;
 
 #ifndef NDEBUG
index 8d5e52524447c268b254151631f0b0c1c4054d5c..3b87864e1f2566be769b8b8bf2b94dda54d31e63 100644 (file)
@@ -406,7 +406,6 @@ faulthandler_exc_handler(struct _EXCEPTION_POINTERS *exc_info)
 {
     const int fd = fatal_error.fd;
     DWORD code = exc_info->ExceptionRecord->ExceptionCode;
-    DWORD flags = exc_info->ExceptionRecord->ExceptionFlags;
 
     if (faulthandler_ignore_exception(code)) {
         /* ignore the exception: call the next exception handler */
index ff798e8a19c0b53549fe9cc70c0678b8314b5b3f..f3ce1fb632226ec9b43483f89737f502761b270c 100644 (file)
@@ -5696,7 +5696,6 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd)
     int result;
 #ifdef MS_WINDOWS
     int error = 0;
-    int pathError = 0;
     SECURITY_ATTRIBUTES secAttr = { sizeof(secAttr) };
     SECURITY_ATTRIBUTES *pSecAttr = NULL;
 #endif
index efdf8addc061863d7654d252ae60c78214090418..e779224fd3b092daefa3bb6a88e6d8a7eac841d4 100644 (file)
@@ -31,8 +31,6 @@ static BOOL clinic_HKEY_converter(winreg_state *st, PyObject *ob, void *p);
 static PyObject *PyHKEY_FromHKEY(winreg_state *st, HKEY h);
 static BOOL PyHKEY_Close(winreg_state *st, PyObject *obHandle);
 
-static char errNotAHandle[] = "Object is not a handle";
-
 /* The win32api module reports the function name that failed,
    but this concept is not in the Python core.
    Hopefully it will one day, and in the meantime I don't
@@ -2074,7 +2072,7 @@ static struct PyMethodDef winreg_methods[] = {
     WINREG_SAVEKEY_METHODDEF
     WINREG_SETVALUE_METHODDEF
     WINREG_SETVALUEEX_METHODDEF
-    NULL,
+    {NULL},
 };
 
 #define ADD_INT(VAL) do {                               \
index 68d24bc6b934653621d609e299b9bbd60fd8a37b..95b64ed76fb974e428059137c4384c6de6652bc4 100644 (file)
@@ -55,7 +55,9 @@ int _Py_open_cloexec_works = -1;
 
 // mbstowcs() and mbrtowc() errors
 static const size_t DECODE_ERROR = ((size_t)-1);
+#ifdef HAVE_MBRTOWC
 static const size_t INCOMPLETE_CHARACTER = (size_t)-2;
+#endif
 
 
 static int
@@ -129,6 +131,7 @@ is_valid_wide_char(wchar_t ch)
         // Reject lone surrogate characters
         return 0;
     }
+#if SIZEOF_WCHAR_T > 2
     if (ch > MAX_UNICODE) {
         // bpo-35883: Reject characters outside [U+0000; U+10ffff] range.
         // The glibc mbstowcs() UTF-8 decoder does not respect the RFC 3629,
@@ -136,6 +139,7 @@ is_valid_wide_char(wchar_t ch)
         // https://sourceware.org/bugzilla/show_bug.cgi?id=2373
         return 0;
     }
+#endif
     return 1;
 }
 
index c06ae90ee2bd11e4e36276b5edc5916e6a550f86..0fe9f894f05af4eab876c0da49880dc08875dced 100644 (file)
@@ -2531,7 +2531,9 @@ sys__is_gil_enabled_impl(PyObject *module)
 }
 
 
+#ifndef MS_WINDOWS
 static PerfMapState perf_map_state;
+#endif
 
 PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void) {
 #ifndef MS_WINDOWS