Skip to content

Commit 98ea54c

Browse files
committed
Issue #22156: Fix "comparison between signed and unsigned integers" compiler
warnings in the Python/ subdirectory.
1 parent eae9470 commit 98ea54c

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

Python/bltinmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ source_as_string(PyObject *cmd, char *funcname, char *what, PyCompilerFlags *cf)
581581
return NULL;
582582
}
583583

584-
if (strlen(str) != size) {
584+
if (strlen(str) != (size_t)size) {
585585
PyErr_SetString(PyExc_TypeError,
586586
"source code string cannot contain null bytes");
587587
return NULL;

Python/getargs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
872872
STORE_SIZE(count);
873873
format++;
874874
} else {
875-
if (strlen(*p) != count)
875+
if (strlen(*p) != (size_t)count)
876876
return converterr(
877877
"bytes without null bytes",
878878
arg, msgbuf, bufsize);
@@ -994,7 +994,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
994994
*p = PyUnicode_AsUnicodeAndSize(arg, &len);
995995
if (*p == NULL)
996996
RETURN_ERR_OCCURRED;
997-
if (Py_UNICODE_strlen(*p) != len)
997+
if (Py_UNICODE_strlen(*p) != (size_t)len)
998998
return converterr(
999999
"str without null characters or None",
10001000
arg, msgbuf, bufsize);

Python/pythonrun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,7 @@ print_error_text(PyObject *f, int offset, PyObject *text_obj)
17381738
return;
17391739

17401740
if (offset >= 0) {
1741-
if (offset > 0 && offset == strlen(text) && text[offset - 1] == '\n')
1741+
if (offset > 0 && (size_t)offset == strlen(text) && text[offset - 1] == '\n')
17421742
offset--;
17431743
for (;;) {
17441744
nl = strchr(text, '\n');

Python/thread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ PyThread_GetInfo(void)
431431
&& defined(_CS_GNU_LIBPTHREAD_VERSION))
432432
value = NULL;
433433
len = confstr(_CS_GNU_LIBPTHREAD_VERSION, buffer, sizeof(buffer));
434-
if (1 < len && len < sizeof(buffer)) {
434+
if (1 < len && (size_t)len < sizeof(buffer)) {
435435
value = PyUnicode_DecodeFSDefaultAndSize(buffer, len-1);
436436
if (value == NULL)
437437
PyErr_Clear();

Python/traceback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ _Py_FindSourceFile(PyObject *filename, char* namebuf, size_t namelen, PyObject *
198198
}
199199
strcpy(namebuf, PyBytes_AS_STRING(path));
200200
Py_DECREF(path);
201-
if (strlen(namebuf) != len)
201+
if (strlen(namebuf) != (size_t)len)
202202
continue; /* v contains '\0' */
203203
if (len > 0 && namebuf[len-1] != SEP)
204204
namebuf[len++] = SEP;

0 commit comments

Comments
 (0)