diff -r 39511e854e6d Modules/_bz2module.c --- a/Modules/_bz2module.c +++ b/Modules/_bz2module.c @@ -427,7 +427,7 @@ decompress_buf(BZ2Decompressor *d, Py_ss PyObject *result; bz_stream *bzs = &d->bzs; - if (max_length < 0 || max_length >= INITIAL_BUFFER_SIZE) + if ((size_t)max_length >= (size_t)INITIAL_BUFFER_SIZE) result = PyBytes_FromStringAndSize(NULL, INITIAL_BUFFER_SIZE); else result = PyBytes_FromStringAndSize(NULL, max_length); diff -r 39511e854e6d Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -689,7 +689,7 @@ deque_inplace_repeat(dequeobject *deque, /* common case, repeating a single element */ PyObject *item = deque->leftblock->data[deque->leftindex]; - if (deque->maxlen >= 0 && n > deque->maxlen) + if ((size_t)n > (size_t)deque->maxlen) n = deque->maxlen; deque->state++; diff -r 39511e854e6d Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -4230,7 +4230,7 @@ Array_item(PyObject *myself, Py_ssize_t StgDictObject *stgdict; - if (index < 0 || index >= self->b_length) { + if ((size_t)index >= (size_t)self->b_length) { PyErr_SetString(PyExc_IndexError, "invalid index"); return NULL; @@ -4373,7 +4373,7 @@ Array_ass_item(PyObject *myself, Py_ssiz stgdict = PyObject_stgdict((PyObject *)self); assert(stgdict); /* Cannot be NULL for array object instances */ - if (index < 0 || index >= stgdict->length) { + if ((size_t)index >= (size_t)stgdict->length) { PyErr_SetString(PyExc_IndexError, "invalid index"); return -1; diff -r 39511e854e6d Modules/_ctypes/cfield.c --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1140,7 +1140,7 @@ c_set(void *ptr, PyObject *value, Py_ssi if (PyLong_Check(value)) { long longval = PyLong_AS_LONG(value); - if (longval < 0 || longval >= 256) + if ((unsigned long)longval >= 256u) goto error; *(char *)ptr = (char)longval; _RET(value); diff -r 39511e854e6d Modules/_datetimemodule.c --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -466,7 +466,7 @@ normalize_pair(int *hi, int *lo, int fac { assert(factor > 0); assert(lo != hi); - if (*lo < 0 || *lo >= factor) { + if ((unsigned)*lo >= (unsigned)factor) { const int num_hi = divmod(*lo, factor, lo); const int new_hi = *hi + num_hi; assert(! SIGNED_ADD_OVERFLOWED(new_hi, *hi, num_hi)); @@ -484,14 +484,14 @@ normalize_pair(int *hi, int *lo, int fac static void normalize_d_s_us(int *d, int *s, int *us) { - if (*us < 0 || *us >= 1000000) { + if ((unsigned)*us >= 1000000u) { normalize_pair(s, us, 1000000); /* |s| can't be bigger than about * |original s| + |original us|/1000000 now. */ } - if (*s < 0 || *s >= 24*3600) { + if ((unsigned)*s >= (unsigned)(24 * 3600)) { normalize_pair(d, s, 24*3600); /* |d| can't be bigger than about * |original d| + diff -r 39511e854e6d Modules/_decimal/_decimal.c --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -1334,12 +1334,12 @@ context_repr(PyDecContextObject *self) mem = MPD_MAX_SIGNAL_LIST; n = mpd_lsnprint_signals(flags, mem, ctx->status, dec_signal_string); - if (n < 0 || n >= mem) { + if ((unsigned)n >= (unsigned)mem) { INTERNAL_ERROR_PTR("context_repr"); } n = mpd_lsnprint_signals(traps, mem, ctx->traps, dec_signal_string); - if (n < 0 || n >= mem) { + if ((unsigned)n >= (unsigned)mem) { INTERNAL_ERROR_PTR("context_repr"); } @@ -2496,7 +2496,7 @@ dectuple_as_str(PyObject *dectuple) } n = snprintf(cp, mem, "%s", sign_special); - if (n < 0 || n >= mem) { + if ((size_t)n >= (size_t)mem) { PyErr_SetString(PyExc_RuntimeError, "internal error in dec_sequence_as_str"); goto error; @@ -2536,7 +2536,7 @@ dectuple_as_str(PyObject *dectuple) /* not a special number */ *cp++ = 'E'; n = snprintf(cp, MPD_EXPDIGITS+2, "%" PRI_mpd_ssize_t, exp); - if (n < 0 || n >= MPD_EXPDIGITS+2) { + if ((unsigned)n >= (unsigned)(MPD_EXPDIGITS + 2)) { PyErr_SetString(PyExc_RuntimeError, "internal error in dec_sequence_as_str"); goto error; diff -r 39511e854e6d Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1109,7 +1109,7 @@ static PyObject * the calls to the C API are simple enough that they can't trigger any thread switch. */ n = Py_SAFE_DOWNCAST(READAHEAD(self), Py_off_t, Py_ssize_t); - if (limit >= 0 && n > limit) + if ((size_t)n > (size_t)limit) n = limit; start = self->buffer + self->pos; s = memchr(start, '\n', n); @@ -1161,7 +1161,7 @@ static PyObject * goto end; if (n <= 0) break; - if (limit >= 0 && n > limit) + if ((size_t)n > (size_t)limit) n = limit; start = self->buffer; end = start + n; diff -r 39511e854e6d Modules/_lzmamodule.c --- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -896,7 +896,7 @@ decompress_buf(Decompressor *d, Py_ssize PyObject *result; lzma_stream *lzs = &d->lzs; - if (max_length < 0 || max_length >= INITIAL_BUFFER_SIZE) + if ((size_t)max_length >= (size_t)INITIAL_BUFFER_SIZE) result = PyBytes_FromStringAndSize(NULL, INITIAL_BUFFER_SIZE); else result = PyBytes_FromStringAndSize(NULL, max_length); diff -r 39511e854e6d Modules/_pickle.c --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -1306,7 +1306,7 @@ static int static PyObject * _Unpickler_MemoGet(UnpicklerObject *self, Py_ssize_t idx) { - if (idx < 0 || idx >= self->memo_size) + if ((size_t)idx >= (size_t)self->memo_size) return NULL; return self->memo[idx]; diff -r 39511e854e6d Modules/_sre.c --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -2006,7 +2006,7 @@ match_getslice_by_index(MatchObject* sel PyObject *result; void* ptr; - if (index < 0 || index >= self->groups) { + if ((size_t)index >= (size_t)self->groups) { /* raise IndexError if we were given a bad group number */ PyErr_SetString( PyExc_IndexError, @@ -2226,7 +2226,7 @@ static Py_ssize_t { Py_ssize_t index = match_getindex(self, group); - if (index < 0 || index >= self->groups) { + if ((size_t)index >= (size_t)self->groups) { PyErr_SetString( PyExc_IndexError, "no such group" @@ -2253,7 +2253,7 @@ static Py_ssize_t { Py_ssize_t index = match_getindex(self, group); - if (index < 0 || index >= self->groups) { + if ((size_t)index >= (size_t)self->groups) { PyErr_SetString( PyExc_IndexError, "no such group" @@ -2307,7 +2307,7 @@ static PyObject * { Py_ssize_t index = match_getindex(self, group); - if (index < 0 || index >= self->groups) { + if ((size_t)index >= (size_t)self->groups) { PyErr_SetString( PyExc_IndexError, "no such group" diff -r 39511e854e6d Modules/_testbuffer.c --- a/Modules/_testbuffer.c +++ b/Modules/_testbuffer.c @@ -1568,7 +1568,7 @@ ptr_from_index(Py_buffer *base, Py_ssize if (index < 0) { index += nitems; } - if (index < 0 || index >= nitems) { + if ((size_t)index >= (size_t)nitems) { PyErr_SetString(PyExc_IndexError, "index out of bounds"); return NULL; } @@ -2335,7 +2335,7 @@ get_pointer(PyObject *self, PyObject *ar indices[i] = PyLong_AsSsize_t(x); if (PyErr_Occurred()) goto out; - if (indices[i] < 0 || indices[i] >= view.shape[i]) { + if ((size_t)indices[i] >= (size_t)view.shape[i]) { PyErr_Format(PyExc_ValueError, "get_pointer(): invalid index %zd at position %zd", indices[i], i); diff -r 39511e854e6d Modules/_winapi.c --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -1330,12 +1330,12 @@ static PyObject * return NULL; } nhandles = PySequence_Length(handle_seq); - if (nhandles == -1) - return NULL; - if (nhandles < 0 || nhandles >= MAXIMUM_WAIT_OBJECTS - 1) { - PyErr_Format(PyExc_ValueError, - "need at most %zd handles, got a sequence of length %zd", - MAXIMUM_WAIT_OBJECTS - 1, nhandles); + if ((size_t)nhandles >= (size_t)(MAXIMUM_WAIT_OBJECTS - 1)) { + if (nhandles != -1 && !PyErr_Occurred()) { + PyErr_Format(PyExc_ValueError, + "need at most %zd handles, got a sequence of length %zd", + (Py_ssize_t)(MAXIMUM_WAIT_OBJECTS - 1), nhandles); + } return NULL; } for (i = 0; i < nhandles; i++) { diff -r 39511e854e6d Modules/arraymodule.c --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -716,7 +716,7 @@ array_length(arrayobject *a) static PyObject * array_item(arrayobject *a, Py_ssize_t i) { - if (i < 0 || i >= Py_SIZE(a)) { + if ((size_t)i >= (size_t)Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "array index out of range"); return NULL; } @@ -884,7 +884,7 @@ array_del_slice(arrayobject *a, Py_ssize static int array_ass_item(arrayobject *a, Py_ssize_t i, PyObject *v) { - if (i < 0 || i >= Py_SIZE(a)) { + if ((size_t)i >= (size_t)Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "array assignment index out of range"); return -1; @@ -1156,7 +1156,7 @@ array_array_pop_impl(arrayobject *self, } if (i < 0) i += Py_SIZE(self); - if (i < 0 || i >= Py_SIZE(self)) { + if ((size_t)i >= (size_t)Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "pop index out of range"); return NULL; } @@ -2336,7 +2336,7 @@ array_ass_subscr(arrayobject* self, PyOb return -1; if (i < 0) i += Py_SIZE(self); - if (i < 0 || i >= Py_SIZE(self)) { + if ((size_t)i >= (size_t)Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "array assignment index out of range"); return -1; diff -r 39511e854e6d Modules/audioop.c --- a/Modules/audioop.c +++ b/Modules/audioop.c @@ -415,7 +415,7 @@ audioop_getsample_impl(PyObject *module, if (!audioop_check_parameters(fragment->len, width)) return NULL; - if (index < 0 || index >= fragment->len/width) { + if ((size_t)index >= (size_t)(fragment->len / width)) { PyErr_SetString(AudioopError, "Index out of range"); return NULL; } diff -r 39511e854e6d Modules/gcmodule.c --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -1210,7 +1210,7 @@ gc_collect(PyObject *self, PyObject *arg if (!PyArg_ParseTupleAndKeywords(args, kws, "|i", keywords, &genarg)) return NULL; - else if (genarg < 0 || genarg >= NUM_GENERATIONS) { + else if ((unsigned)genarg >= (unsigned)NUM_GENERATIONS) { PyErr_SetString(PyExc_ValueError, "invalid generation"); return NULL; } diff -r 39511e854e6d Modules/mmapmodule.c --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -779,7 +779,7 @@ static PyObject * mmap_item(mmap_object *self, Py_ssize_t i) { CHECK_VALID(NULL); - if (i < 0 || i >= self->size) { + if ((size_t)i >= (size_t)self->size) { PyErr_SetString(PyExc_IndexError, "mmap index out of range"); return NULL; } @@ -796,7 +796,7 @@ mmap_subscript(mmap_object *self, PyObje return NULL; if (i < 0) i += self->size; - if (i < 0 || i >= self->size) { + if ((size_t)i >= (size_t)self->size) { PyErr_SetString(PyExc_IndexError, "mmap index out of range"); return NULL; @@ -864,7 +864,7 @@ mmap_ass_item(mmap_object *self, Py_ssiz const char *buf; CHECK_VALID(-1); - if (i < 0 || i >= self->size) { + if ((size_t)i >= (size_t)self->size) { PyErr_SetString(PyExc_IndexError, "mmap index out of range"); return -1; } @@ -901,7 +901,7 @@ mmap_ass_subscript(mmap_object *self, Py return -1; if (i < 0) i += self->size; - if (i < 0 || i >= self->size) { + if ((size_t)i >= (size_t)self->size) { PyErr_SetString(PyExc_IndexError, "mmap index out of range"); return -1; diff -r 39511e854e6d Modules/unicodedata.c --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -412,7 +412,7 @@ unicodedata_UCD_decomposition_impl(PyObj return PyUnicode_FromString(""); /* unassigned */ } - if (code < 0 || code >= 0x110000) + if ((unsigned)code >= 0x110000u) index = 0; else { index = decomp_index1[(code>>DECOMP_SHIFT)]; diff -r 39511e854e6d Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -47,7 +47,7 @@ static int Py_DECREF(index); } - if (face_value < 0 || face_value >= 256) { + if ((unsigned long)face_value >= 256u) { /* this includes the OverflowError in case the long is too large */ PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); *value = -1; @@ -373,7 +373,7 @@ bytearray_getitem(PyByteArrayObject *sel { if (i < 0) i += Py_SIZE(self); - if (i < 0 || i >= Py_SIZE(self)) { + if ((size_t)i >= (size_t)Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); return NULL; } @@ -392,7 +392,7 @@ bytearray_subscript(PyByteArrayObject *s if (i < 0) i += PyByteArray_GET_SIZE(self); - if (i < 0 || i >= Py_SIZE(self)) { + if ((size_t)i >= (size_t)Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); return NULL; } @@ -578,7 +578,7 @@ bytearray_setitem(PyByteArrayObject *sel if (i < 0) i += Py_SIZE(self); - if (i < 0 || i >= Py_SIZE(self)) { + if ((size_t)i >= (size_t)Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); return -1; } @@ -609,7 +609,7 @@ bytearray_ass_subscript(PyByteArrayObjec if (i < 0) i += PyByteArray_GET_SIZE(self); - if (i < 0 || i >= Py_SIZE(self)) { + if ((size_t)i >= (size_t)Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); return -1; } @@ -1703,7 +1703,7 @@ bytearray_pop_impl(PyByteArrayObject *se } if (index < 0) index += Py_SIZE(self); - if (index < 0 || index >= Py_SIZE(self)) { + if ((size_t)index >= (size_t)Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "pop index out of range"); return NULL; } diff -r 39511e854e6d Objects/bytes_methods.c --- a/Objects/bytes_methods.c +++ b/Objects/bytes_methods.c @@ -657,7 +657,7 @@ int PyBuffer_Release(&varg); return pos >= 0; } - if (ival < 0 || ival >= 256) { + if ((size_t)ival >= 256u) { PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); return -1; } diff -r 39511e854e6d Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -821,7 +821,7 @@ PyObject * assert(PyUnicode_IS_ASCII(temp)); pbuf = (const char *)PyUnicode_1BYTE_DATA(temp); len = PyUnicode_GET_LENGTH(temp); - if (prec >= 0 && len > prec) + if ((size_t)len > (size_t)prec) len = prec; break; @@ -831,7 +831,7 @@ PyObject * temp = format_obj(v, &pbuf, &len); if (temp == NULL) goto error; - if (prec >= 0 && len > prec) + if ((size_t)len > (size_t)prec) len = prec; break; @@ -1493,7 +1493,7 @@ bytes_contains(PyObject *self, PyObject static PyObject * bytes_item(PyBytesObject *a, Py_ssize_t i) { - if (i < 0 || i >= Py_SIZE(a)) { + if ((size_t)i >= (size_t)Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "index out of range"); return NULL; } @@ -1629,7 +1629,7 @@ bytes_subscript(PyBytesObject* self, PyO return NULL; if (i < 0) i += PyBytes_GET_SIZE(self); - if (i < 0 || i >= PyBytes_GET_SIZE(self)) { + if ((size_t)i >= (size_t)PyBytes_GET_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "index out of range"); return NULL; @@ -2688,7 +2688,7 @@ static PyObject * goto error; /* Range check */ - if (value < 0 || value >= 256) { + if ((size_t)value >= 256u) { PyErr_SetString(PyExc_ValueError, "bytes must be in range(0, 256)"); goto error; diff -r 39511e854e6d Objects/exceptions.c --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -2921,7 +2921,7 @@ static int if (colon_index < -1) { return -1; } - if (colon_index >= 0 && colon_index < text_len) { + if ((size_t)colon_index < (size_t)text_len) { /* Check again, starting from just after the colon */ if (_check_for_legacy_statements(self, colon_index+1) < 0) { return -1; diff -r 39511e854e6d Objects/listobject.c --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -202,7 +202,7 @@ PyList_GetItem(PyObject *op, Py_ssize_t PyErr_BadInternalCall(); return NULL; } - if (i < 0 || i >= Py_SIZE(op)) { + if ((size_t)i >= (size_t)Py_SIZE(op)) { if (indexerr == NULL) { indexerr = PyUnicode_FromString( "list index out of range"); @@ -225,7 +225,7 @@ PyList_SetItem(PyObject *op, Py_ssize_t PyErr_BadInternalCall(); return -1; } - if (i < 0 || i >= Py_SIZE(op)) { + if ((size_t)i >= (size_t)Py_SIZE(op)) { Py_XDECREF(newitem); PyErr_SetString(PyExc_IndexError, "list assignment index out of range"); @@ -414,7 +414,7 @@ list_contains(PyListObject *a, PyObject static PyObject * list_item(PyListObject *a, Py_ssize_t i) { - if (i < 0 || i >= Py_SIZE(a)) { + if ((size_t)i >= (size_t)Py_SIZE(a)) { if (indexerr == NULL) { indexerr = PyUnicode_FromString( "list index out of range"); @@ -733,7 +733,7 @@ list_inplace_repeat(PyListObject *self, static int list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v) { - if (i < 0 || i >= Py_SIZE(a)) { + if ((size_t)i >= (size_t)Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "list assignment index out of range"); return -1; @@ -927,7 +927,7 @@ listpop(PyListObject *self, PyObject *ar } if (i < 0) i += Py_SIZE(self); - if (i < 0 || i >= Py_SIZE(self)) { + if ((size_t)i >= (size_t)Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "pop index out of range"); return NULL; } @@ -2922,7 +2922,7 @@ listreviter_next(listreviterobject *it) assert(PyList_Check(seq)); index = it->it_index; - if (index>=0 && index < PyList_GET_SIZE(seq)) { + if ((size_t)index < (size_t)PyList_GET_SIZE(seq)) { item = PyList_GET_ITEM(seq, index); it->it_index--; Py_INCREF(item); diff -r 39511e854e6d Objects/memoryobject.c --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -2175,7 +2175,7 @@ lookup_dimension(Py_buffer *view, char * if (index < 0) { index += nitems; } - if (index < 0 || index >= nitems) { + if ((size_t)index >= (size_t)nitems) { PyErr_Format(PyExc_IndexError, "index out of bounds on dimension %d", dim + 1); return NULL; diff -r 39511e854e6d Objects/tupleobject.c --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -149,7 +149,7 @@ PyTuple_GetItem(PyObject *op, Py_ssize_t PyErr_BadInternalCall(); return NULL; } - if (i < 0 || i >= Py_SIZE(op)) { + if ((size_t)i >= (size_t)Py_SIZE(op)) { PyErr_SetString(PyExc_IndexError, "tuple index out of range"); return NULL; } @@ -165,7 +165,7 @@ PyTuple_SetItem(PyObject *op, Py_ssize_t PyErr_BadInternalCall(); return -1; } - if (i < 0 || i >= Py_SIZE(op)) { + if ((size_t)i >= (size_t)Py_SIZE(op)) { Py_XDECREF(newitem); PyErr_SetString(PyExc_IndexError, "tuple assignment index out of range"); @@ -389,7 +389,7 @@ tuplecontains(PyTupleObject *a, PyObject static PyObject * tupleitem(PyTupleObject *a, Py_ssize_t i) { - if (i < 0 || i >= Py_SIZE(a)) { + if ((size_t)i >= (size_t)Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "tuple index out of range"); return NULL; } diff -r 39511e854e6d Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4168,7 +4168,7 @@ PyUnicode_ReadChar(PyObject *unicode, Py PyErr_BadArgument(); return (Py_UCS4)-1; } - if (index < 0 || index >= PyUnicode_GET_LENGTH(unicode)) { + if ((size_t)index >= (size_t)PyUnicode_GET_LENGTH(unicode)) { PyErr_SetString(PyExc_IndexError, "string index out of range"); return (Py_UCS4)-1; } @@ -4185,7 +4185,7 @@ PyUnicode_WriteChar(PyObject *unicode, P return -1; } assert(PyUnicode_IS_READY(unicode)); - if (index < 0 || index >= PyUnicode_GET_LENGTH(unicode)) { + if ((size_t)index >= (size_t)PyUnicode_GET_LENGTH(unicode)) { PyErr_SetString(PyExc_IndexError, "string index out of range"); return -1; } @@ -11547,7 +11547,7 @@ unicode_getitem(PyObject *self, Py_ssize PyErr_BadArgument(); return NULL; } - if (index < 0 || index >= PyUnicode_GET_LENGTH(self)) { + if ((size_t)index >= (size_t)PyUnicode_GET_LENGTH(self)) { PyErr_SetString(PyExc_IndexError, "string index out of range"); return NULL; } @@ -14585,7 +14585,7 @@ unicode_format_arg_output(struct unicode /* Truncate the string for "s", "r" and "a" formats if the precision is set */ if (arg->ch == 's' || arg->ch == 'r' || arg->ch == 'a') { - if (arg->prec >= 0 && len > arg->prec) + if ((size_t)len > (size_t)arg->prec) len = arg->prec; } diff -r 39511e854e6d Parser/acceler.c --- a/Parser/acceler.c +++ b/Parser/acceler.c @@ -102,7 +102,7 @@ fixstate(grammar *g, state *s) } else if (lbl == EMPTY) s->s_accept = 1; - else if (lbl >= 0 && lbl < nl) + else if ((unsigned)lbl < (unsigned)nl) accel[lbl] = a->a_arrow; } while (nl > 0 && accel[nl-1] == -1) diff -r 39511e854e6d Python/marshal.c --- a/Python/marshal.c +++ b/Python/marshal.c @@ -1426,7 +1426,7 @@ r_object(RFILE *p) case TYPE_REF: n = r_long(p); - if (n < 0 || n >= PyList_GET_SIZE(p->refs)) { + if ((size_t)n >= (size_t)PyList_GET_SIZE(p->refs)) { if (n == -1 && PyErr_Occurred()) break; PyErr_SetString(PyExc_ValueError, "bad marshal data (invalid reference)"); diff -r 39511e854e6d Python/pystrtod.c --- a/Python/pystrtod.c +++ b/Python/pystrtod.c @@ -674,8 +674,7 @@ ensure_decimal_point(char* buffer, size_ arrive here as a result of using the empty format code or repr/str builtins and those never want an upper case 'E' */ written = PyOS_snprintf(p, buf_avail, "e%+.02d", digit_count-1); - if (!(0 <= written && - written < Py_SAFE_DOWNCAST(buf_avail, size_t, int))) + if ((size_t)written >= buf_avail) /* output truncated, or something else bad happened */ return NULL; remove_trailing_zeros(buffer);