diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2003-11-03 20:58:28 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2003-11-03 20:58:28 (GMT) |
commit | ceac90aecb0996ddb4a97998ed60d724d936e60b (patch) | |
tree | 5b43908e7a3e4b834535efb36b2ac22954013c0f /Objects | |
parent | a703a21b486b4eb47d9873fb1c7de7008530ae93 (diff) | |
download | cpython-ceac90aecb0996ddb4a97998ed60d724d936e60b.zip cpython-ceac90aecb0996ddb4a97998ed60d724d936e60b.tar.gz cpython-ceac90aecb0996ddb4a97998ed60d724d936e60b.tar.bz2 |
Fix compiler warning about possible use of n without assignment.
Also fix use of n for two different variables in two different blocks.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/listobject.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index 23d7d9a..fd98b63 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -1848,7 +1848,7 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds) PyObject *result = NULL; /* guilty until proved innocent */ int reverse = 0; PyObject *keyfunc = NULL; - int i, n; + int i, len = 0; PyObject *key, *value, *kvpair; static char *kwlist[] = {"cmp", "key", "reverse", 0}; @@ -1871,10 +1871,11 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds) Py_XINCREF(compare); if (keyfunc != NULL) { - n = PyList_GET_SIZE(self); - for (i=0 ; i<n ; i++) { + len = PyList_GET_SIZE(self); + for (i=0 ; i < len ; i++) { value = PyList_GET_ITEM(self, i); - key = PyObject_CallFunctionObjArgs(keyfunc, value, NULL); + key = PyObject_CallFunctionObjArgs(keyfunc, value, + NULL); if (key == NULL) goto dsu_fail; kvpair = build_sortwrapper(key, value); @@ -1967,7 +1968,7 @@ fail: merge_freemem(&ms); if (keyfunc != NULL) { - for (i=0 ; i<n ; i++) { + for (i=0 ; i < len ; i++) { kvpair = PyList_GET_ITEM(self, i); value = sortwrapper_getvalue(kvpair); PyList_SET_ITEM(self, i, value); |