[Python-checkins] r78183 - python/trunk/Objects/listobject.c

mark.dickinson python-checkins at python.org
Sun Feb 14 13:16:44 CET 2010


Author: mark.dickinson
Date: Sun Feb 14 13:16:43 2010
New Revision: 78183
Log:
Silence some 'comparison between signed and unsigned' compiler warnings.
Modified:
 python/trunk/Objects/listobject.c
Modified: python/trunk/Objects/listobject.c
==============================================================================
--- python/trunk/Objects/listobject.c	(original)
+++ python/trunk/Objects/listobject.c	Sun Feb 14 13:16:43 2010
@@ -126,11 +126,11 @@
 		PyErr_BadInternalCall();
 		return NULL;
 	}
-	nbytes = size * sizeof(PyObject *);
 	/* Check for overflow without an actual overflow,
 	 * which can cause compiler to optimise out */
-	if (size > PY_SIZE_MAX / sizeof(PyObject *))
+	if ((size_t)size > PY_SIZE_MAX / sizeof(PyObject *))
 		return PyErr_NoMemory();
+	nbytes = size * sizeof(PyObject *);
 	if (numfree) {
 		numfree--;
 		op = free_list[numfree];
@@ -1432,7 +1432,7 @@
 	 * we don't care what's in the block.
 	 */
 	merge_freemem(ms);
-	if (need > PY_SSIZE_T_MAX / sizeof(PyObject*)) {
+	if ((size_t)need > PY_SSIZE_T_MAX / sizeof(PyObject*)) {
 		PyErr_NoMemory();
 		return -1;
 	}
@@ -2636,7 +2636,8 @@
 				step = -step;
 			}
 
-			assert(slicelength <= PY_SIZE_MAX / sizeof(PyObject*));
+			assert((size_t)slicelength <=
+			 PY_SIZE_MAX / sizeof(PyObject*));
 
 			garbage = (PyObject**)
 				PyMem_MALLOC(slicelength*sizeof(PyObject*));
@@ -2652,13 +2653,13 @@
 			 and then tail end of the list that was not
 			 covered by the slice */
 			for (cur = start, i = 0;
-			 cur < stop;
+			 cur < (size_t)stop;
 			 cur += step, i++) {
 				Py_ssize_t lim = step - 1;
 
 				garbage[i] = PyList_GET_ITEM(self, cur);
 
-				if (cur + step >= Py_SIZE(self)) {
+				if (cur + step >= (size_t)Py_SIZE(self)) {
 					lim = Py_SIZE(self) - cur - 1;
 				}
 
@@ -2667,7 +2668,7 @@
 					lim * sizeof(PyObject *));
 			}
 			cur = start + slicelength*step;
-			if (cur < Py_SIZE(self)) {
+			if (cur < (size_t)Py_SIZE(self)) {
 				memmove(self->ob_item + cur - slicelength,
 					self->ob_item + cur,
 					(Py_SIZE(self) - cur) * 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /