diff options
author | Brett Cannon <bcannon@gmail.com> | 2011-02-22 20:15:44 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2011-02-22 20:15:44 (GMT) |
commit | b94767ff44edf5d461d7cb1c8eb5160f83886358 (patch) | |
tree | b43b482e765b0383b3326779f6815e72b2bacccb /Objects | |
parent | 79da6b7075a3d51ae042e77a2afca827e7bce435 (diff) | |
download | cpython-b94767ff44edf5d461d7cb1c8eb5160f83886358.zip cpython-b94767ff44edf5d461d7cb1c8eb5160f83886358.tar.gz cpython-b94767ff44edf5d461d7cb1c8eb5160f83886358.tar.bz2 |
Issue #8914: fix various warnings from the Clang static analyzer v254.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytearrayobject.c | 5 | ||||
-rw-r--r-- | Objects/fileobject.c | 4 | ||||
-rw-r--r-- | Objects/floatobject.c | 3 | ||||
-rw-r--r-- | Objects/obmalloc.c | 2 | ||||
-rw-r--r-- | Objects/tupleobject.c | 2 | ||||
-rw-r--r-- | Objects/typeobject.c | 2 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 4 | ||||
-rw-r--r-- | Objects/weakrefobject.c | 21 |
8 files changed, 22 insertions, 21 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 7448354..9290d00 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -2439,7 +2439,7 @@ If the argument is omitted, strip trailing ASCII whitespace."); static PyObject * bytearray_rstrip(PyByteArrayObject *self, PyObject *args) { - Py_ssize_t left, right, mysize, argsize; + Py_ssize_t right, mysize, argsize; void *myptr, *argptr; PyObject *arg = Py_None; Py_buffer varg; @@ -2457,11 +2457,10 @@ bytearray_rstrip(PyByteArrayObject *self, PyObject *args) } myptr = self->ob_bytes; mysize = Py_SIZE(self); - left = 0; right = rstrip_helper(myptr, mysize, argptr, argsize); if (arg != Py_None) PyBuffer_Release(&varg); - return PyByteArray_FromStringAndSize(self->ob_bytes + left, right - left); + return PyByteArray_FromStringAndSize(self->ob_bytes, right); } PyDoc_STRVAR(decode_doc, diff --git a/Objects/fileobject.c b/Objects/fileobject.c index d20f196..cffa5de 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -297,8 +297,8 @@ Py_UniversalNewlineFgets(char *buf, int n, FILE *stream, PyObject *fobj) *p++ = c; if (c == '\n') break; } - if ( c == EOF && skipnextlf ) - newlinetypes |= NEWLINE_CR; + /* if ( c == EOF && skipnextlf ) + newlinetypes |= NEWLINE_CR; */ FUNLOCKFILE(stream); *p = '\0'; if ( skipnextlf ) { diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 09c0e961..6d1745e 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -197,7 +197,6 @@ PyFloat_FromString(PyObject *v) Py_DECREF(s_buffer); return NULL; } - last = s + len; } else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, @@ -2246,7 +2245,7 @@ _PyFloat_Pack8(double x, unsigned char *p, int le) /* Eighth byte */ *p = flo & 0xFF; - p += incr; + /* p += incr; */ /* Done */ return 0; diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 3916262..483847c 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -1775,7 +1775,6 @@ _PyObject_DebugMallocStats(void) * will be living in full pools -- would be a shame to miss them. */ for (i = 0; i < maxarenas; ++i) { - uint poolsinarena; uint j; uptr base = arenas[i].address; @@ -1784,7 +1783,6 @@ _PyObject_DebugMallocStats(void) continue; narenas += 1; - poolsinarena = arenas[i].ntotalpools; numfreepools += arenas[i].nfreepools; /* round up to pool alignment */ diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 72b79c9..bfb7ec7 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -86,7 +86,7 @@ PyTuple_New(register Py_ssize_t size) { return PyErr_NoMemory(); } - nbytes += sizeof(PyTupleObject) - sizeof(PyObject *); + /* nbytes += sizeof(PyTupleObject) - sizeof(PyObject *); */ op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size); if (op == NULL) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 7a1aa77..500dfc9 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -902,7 +902,7 @@ subtype_dealloc(PyObject *self) /* Find the nearest base with a different tp_dealloc */ base = type; - while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { + while ((/*basedealloc =*/ base->tp_dealloc) == subtype_dealloc) { base = base->tp_base; assert(base); } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 57baebd..e7bbd80 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5418,7 +5418,6 @@ PyUnicode_BuildEncodingMap(PyObject* string) if (!result) return NULL; for (i = 0; i < 256; i++) { - key = value = NULL; key = PyLong_FromLong(decode[i]); value = PyLong_FromLong(i); if (!key || !value) @@ -6935,7 +6934,7 @@ PyObject *replace(PyUnicodeObject *self, } } else { - Py_ssize_t n, i, j, e; + Py_ssize_t n, i, j; Py_ssize_t product, new_size, delta; Py_UNICODE *p; @@ -6967,7 +6966,6 @@ PyObject *replace(PyUnicodeObject *self, return NULL; i = 0; p = u->str; - e = self->length - str1->length; if (str1->length > 0) { while (n-- > 0) { /* look for next match */ diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 13323cf..dfaa1b9 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -168,13 +168,20 @@ weakref_repr(PyWeakReference *self) PyErr_Clear(); else if (PyUnicode_Check(nameobj)) name = _PyUnicode_AsString(nameobj); - PyOS_snprintf(buffer, sizeof(buffer), - name ? "<weakref at %p; to '%.50s' at %p (%s)>" - : "<weakref at %p; to '%.50s' at %p>", - self, - Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name, - PyWeakref_GET_OBJECT(self), - name); + if (name) + PyOS_snprintf(buffer, sizeof(buffer), + "<weakref at %p; to '%.50s' at %p (%s)>", + self, + Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name, + PyWeakref_GET_OBJECT(self), + name); + else + PyOS_snprintf(buffer, sizeof(buffer), + "<weakref at %p; to '%.50s' at %p>", + self, + Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name, + PyWeakref_GET_OBJECT(self)); + Py_XDECREF(nameobj); } return PyUnicode_FromString(buffer); |