Skip to content

Commit 486d537

Browse files
authored
Fix Windows build warnings (#131487)
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'
1 parent 2433cc7 commit 486d537

File tree

7 files changed

+8
-7
lines changed

7 files changed

+8
-7
lines changed

Modules/_io/fileio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,8 +1293,8 @@ fileio_get_mode(PyObject *op, void *closure)
12931293
static PyObject *
12941294
fileio_get_blksize(PyObject *op, void *closure)
12951295
{
1296-
fileio *self = PyFileIO_CAST(op);
12971296
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
1297+
fileio *self = PyFileIO_CAST(op);
12981298
if (self->stat_atopen != NULL && self->stat_atopen->st_blksize > 1) {
12991299
return PyLong_FromLong(self->stat_atopen->st_blksize);
13001300
}

Modules/_io/winconsoleio.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
331331
int ret = 0;
332332
int rwa = 0;
333333
int fd = -1;
334-
int fd_is_own = 0;
335334
HANDLE handle = NULL;
336335

337336
#ifndef NDEBUG

Modules/faulthandler.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ faulthandler_exc_handler(struct _EXCEPTION_POINTERS *exc_info)
406406
{
407407
const int fd = fatal_error.fd;
408408
DWORD code = exc_info->ExceptionRecord->ExceptionCode;
409-
DWORD flags = exc_info->ExceptionRecord->ExceptionFlags;
410409

411410
if (faulthandler_ignore_exception(code)) {
412411
/* ignore the exception: call the next exception handler */

Modules/posixmodule.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5696,7 +5696,6 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd)
56965696
int result;
56975697
#ifdef MS_WINDOWS
56985698
int error = 0;
5699-
int pathError = 0;
57005699
SECURITY_ATTRIBUTES secAttr = { sizeof(secAttr) };
57015700
SECURITY_ATTRIBUTES *pSecAttr = NULL;
57025701
#endif

PC/winreg.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ static BOOL clinic_HKEY_converter(winreg_state *st, PyObject *ob, void *p);
3131
static PyObject *PyHKEY_FromHKEY(winreg_state *st, HKEY h);
3232
static BOOL PyHKEY_Close(winreg_state *st, PyObject *obHandle);
3333

34-
static char errNotAHandle[] = "Object is not a handle";
35-
3634
/* The win32api module reports the function name that failed,
3735
but this concept is not in the Python core.
3836
Hopefully it will one day, and in the meantime I don't
@@ -2074,7 +2072,7 @@ static struct PyMethodDef winreg_methods[] = {
20742072
WINREG_SAVEKEY_METHODDEF
20752073
WINREG_SETVALUE_METHODDEF
20762074
WINREG_SETVALUEEX_METHODDEF
2077-
NULL,
2075+
{NULL},
20782076
};
20792077

20802078
#define ADD_INT(VAL) do { \

Python/fileutils.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ int _Py_open_cloexec_works = -1;
5555

5656
// mbstowcs() and mbrtowc() errors
5757
static const size_t DECODE_ERROR = ((size_t)-1);
58+
#ifdef HAVE_MBRTOWC
5859
static const size_t INCOMPLETE_CHARACTER = (size_t)-2;
60+
#endif
5961

6062

6163
static int
@@ -129,13 +131,15 @@ is_valid_wide_char(wchar_t ch)
129131
// Reject lone surrogate characters
130132
return 0;
131133
}
134+
#if SIZEOF_WCHAR_T > 2
132135
if (ch > MAX_UNICODE) {
133136
// bpo-35883: Reject characters outside [U+0000; U+10ffff] range.
134137
// The glibc mbstowcs() UTF-8 decoder does not respect the RFC 3629,
135138
// it creates characters outside the [U+0000; U+10ffff] range:
136139
// https://sourceware.org/bugzilla/show_bug.cgi?id=2373
137140
return 0;
138141
}
142+
#endif
139143
return 1;
140144
}
141145

Python/sysmodule.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,7 +2531,9 @@ sys__is_gil_enabled_impl(PyObject *module)
25312531
}
25322532

25332533

2534+
#ifndef MS_WINDOWS
25342535
static PerfMapState perf_map_state;
2536+
#endif
25352537

25362538
PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void) {
25372539
#ifndef MS_WINDOWS

0 commit comments

Comments
 (0)