From d5fdc069faeb7efc57584abe96010aba82cc83c8 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 14 Feb 2010 13:40:30 +0000 Subject: [PATCH] Silence more 'comparison between signed and unsigned' warnings. --- Include/pymem.h | 8 ++++---- Modules/arraymodule.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Include/pymem.h b/Include/pymem.h index 966c0f5a09f..10b5bea5eb8 100644 --- a/Include/pymem.h +++ b/Include/pymem.h @@ -90,10 +90,10 @@ PyAPI_FUNC(void) PyMem_Free(void *); */ #define PyMem_New(type, n) \ - ( ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ ( (type *) PyMem_Malloc((n) * sizeof(type)) ) ) #define PyMem_NEW(type, n) \ - ( ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) ) /* @@ -103,10 +103,10 @@ PyAPI_FUNC(void) PyMem_Free(void *); * caller's memory error handler to not lose track of it. */ #define PyMem_Resize(p, type, n) \ - ( (p) = ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ (type *) PyMem_Realloc((p), (n) * sizeof(type)) ) #define PyMem_RESIZE(p, type, n) \ - ( (p) = ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) /* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index c631b618891..ef6fb879cb7 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1804,14 +1804,14 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) cur += step, i++) { Py_ssize_t lim = step - 1; - if (cur + step >= Py_SIZE(self)) + if (cur + step >= (size_t)Py_SIZE(self)) lim = Py_SIZE(self) - cur - 1; memmove(self->ob_item + (cur - i) * itemsize, self->ob_item + (cur + 1) * itemsize, lim * itemsize); } cur = start + slicelength * step; - if (cur < Py_SIZE(self)) { + if (cur < (size_t)Py_SIZE(self)) { memmove(self->ob_item + (cur-slicelength) * itemsize, self->ob_item + cur * itemsize, (Py_SIZE(self) - cur) * itemsize);