mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Issue #8914: fix various warnings from the Clang static analyzer v254.
This commit is contained in:
parent
79da6b7075
commit
b94767ff44
36 changed files with 69 additions and 84 deletions
|
|
@ -52,7 +52,7 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
|
|||
{
|
||||
CFieldObject *self;
|
||||
PyObject *proto;
|
||||
Py_ssize_t size, align, length;
|
||||
Py_ssize_t size, align;
|
||||
SETFUNC setfunc = NULL;
|
||||
GETFUNC getfunc = NULL;
|
||||
StgDictObject *dict;
|
||||
|
|
@ -106,7 +106,6 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
|
|||
}
|
||||
|
||||
size = dict->size;
|
||||
length = dict->length;
|
||||
proto = desc;
|
||||
|
||||
/* Field descriptors for 'c_char * n' are be scpecial cased to
|
||||
|
|
|
|||
|
|
@ -1461,7 +1461,7 @@ delta_to_microseconds(PyDateTime_Delta *self)
|
|||
goto Done;
|
||||
Py_DECREF(x1);
|
||||
Py_DECREF(x2);
|
||||
x1 = x2 = NULL;
|
||||
/* x1 = */ x2 = NULL;
|
||||
|
||||
/* x3 has days+seconds in seconds */
|
||||
x1 = PyNumber_Multiply(x3, us_per_second); /* us */
|
||||
|
|
|
|||
|
|
@ -938,13 +938,11 @@ static int
|
|||
bytesiobuf_getbuffer(bytesiobuf *obj, Py_buffer *view, int flags)
|
||||
{
|
||||
int ret;
|
||||
void *ptr;
|
||||
bytesio *b = (bytesio *) obj->source;
|
||||
if (view == NULL) {
|
||||
b->exports++;
|
||||
return 0;
|
||||
}
|
||||
ptr = (void *) obj;
|
||||
ret = PyBuffer_FillInfo(view, (PyObject*)obj, b->buf, b->string_size,
|
||||
0, flags);
|
||||
if (ret >= 0) {
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict, Py_ssize_t *next
|
|||
PyObject *rval = NULL;
|
||||
Py_ssize_t len = PyUnicode_GET_SIZE(pystr);
|
||||
Py_ssize_t begin = end - 1;
|
||||
Py_ssize_t next = begin;
|
||||
Py_ssize_t next /* = begin */;
|
||||
const Py_UNICODE *buf = PyUnicode_AS_UNICODE(pystr);
|
||||
PyObject *chunks = NULL;
|
||||
PyObject *chunk = NULL;
|
||||
|
|
@ -1532,13 +1532,12 @@ encoder_listencode_dict(PyEncoderObject *s, PyObject *rval, PyObject *dct, Py_ss
|
|||
goto bail;
|
||||
Py_CLEAR(ident);
|
||||
}
|
||||
/* TODO DOES NOT RUN; dead code
|
||||
if (s->indent != Py_None) {
|
||||
/* TODO: DOES NOT RUN */
|
||||
indent_level -= 1;
|
||||
/*
|
||||
yield '\n' + (' ' * (_indent * _current_indent_level))
|
||||
*/
|
||||
}
|
||||
|
||||
yield '\n' + (' ' * (_indent * _current_indent_level))
|
||||
}*/
|
||||
if (PyList_Append(rval, close_dict))
|
||||
goto bail;
|
||||
return 0;
|
||||
|
|
@ -1624,13 +1623,13 @@ encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ss
|
|||
goto bail;
|
||||
Py_CLEAR(ident);
|
||||
}
|
||||
|
||||
/* TODO: DOES NOT RUN
|
||||
if (s->indent != Py_None) {
|
||||
/* TODO: DOES NOT RUN */
|
||||
indent_level -= 1;
|
||||
/*
|
||||
yield '\n' + (' ' * (_indent * _current_indent_level))
|
||||
*/
|
||||
}
|
||||
|
||||
yield '\n' + (' ' * (_indent * _current_indent_level))
|
||||
}*/
|
||||
if (PyList_Append(rval, close_array))
|
||||
goto bail;
|
||||
Py_DECREF(s_fast);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#define PY_SSIZE_T_CLEAN
|
||||
|
||||
#ifdef __sun
|
||||
/* The control message API is only available on Solaris
|
||||
/* The control message API is only available on Solaris
|
||||
if XPG 4.2 or later is requested. */
|
||||
#define _XOPEN_SOURCE 500
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -673,7 +673,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
|
|||
{
|
||||
PyObject* function_result = NULL;
|
||||
PyObject** aggregate_instance;
|
||||
PyObject* aggregate_class;
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
PyGILState_STATE threadstate;
|
||||
|
|
@ -681,8 +680,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
|
|||
threadstate = PyGILState_Ensure();
|
||||
#endif
|
||||
|
||||
aggregate_class = (PyObject*)sqlite3_user_data(context);
|
||||
|
||||
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
|
||||
if (!*aggregate_instance) {
|
||||
/* this branch is executed if there was an exception in the aggregate's
|
||||
|
|
|
|||
|
|
@ -126,11 +126,9 @@ static int pysqlite_cursor_init(pysqlite_Cursor* self, PyObject* args, PyObject*
|
|||
|
||||
static void pysqlite_cursor_dealloc(pysqlite_Cursor* self)
|
||||
{
|
||||
int rc;
|
||||
|
||||
/* Reset the statement if the user has not closed the cursor */
|
||||
if (self->statement) {
|
||||
rc = pysqlite_statement_reset(self->statement);
|
||||
pysqlite_statement_reset(self->statement);
|
||||
Py_DECREF(self->statement);
|
||||
}
|
||||
|
||||
|
|
@ -529,7 +527,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
|
|||
|
||||
if (self->statement != NULL) {
|
||||
/* There is an active statement */
|
||||
rc = pysqlite_statement_reset(self->statement);
|
||||
pysqlite_statement_reset(self->statement);
|
||||
}
|
||||
|
||||
operation_cstr = _PyUnicode_AsStringAndSize(operation, &operation_len);
|
||||
|
|
@ -734,7 +732,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
|
|||
}
|
||||
|
||||
if (multiple) {
|
||||
rc = pysqlite_statement_reset(self->statement);
|
||||
pysqlite_statement_reset(self->statement);
|
||||
}
|
||||
Py_XDECREF(parameters);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -369,11 +369,9 @@ void pysqlite_statement_mark_dirty(pysqlite_Statement* self)
|
|||
|
||||
void pysqlite_statement_dealloc(pysqlite_Statement* self)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (self->st) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
rc = sqlite3_finalize(self->st);
|
||||
sqlite3_finalize(self->st);
|
||||
Py_END_ALLOW_THREADS
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -354,7 +354,6 @@ static PyObject *PySSL_SSLdo_handshake(PySSLSocket *self)
|
|||
|
||||
/* Actually negotiate SSL connection */
|
||||
/* XXX If SSL_do_handshake() returns 0, it's also a failure. */
|
||||
sockstate = 0;
|
||||
do {
|
||||
PySSL_BEGIN_ALLOW_THREADS
|
||||
ret = SSL_do_handshake(self->ssl);
|
||||
|
|
@ -1090,7 +1089,6 @@ static PyObject *PySSL_SSLwrite(PySSLSocket *self, PyObject *args)
|
|||
goto error;
|
||||
}
|
||||
do {
|
||||
err = 0;
|
||||
PySSL_BEGIN_ALLOW_THREADS
|
||||
len = SSL_write(self->ssl, buf.buf, buf.len);
|
||||
err = SSL_get_error(self->ssl, len);
|
||||
|
|
@ -1226,7 +1224,6 @@ static PyObject *PySSL_SSLread(PySSLSocket *self, PyObject *args)
|
|||
}
|
||||
}
|
||||
do {
|
||||
err = 0;
|
||||
PySSL_BEGIN_ALLOW_THREADS
|
||||
count = SSL_read(self->ssl, mem, len);
|
||||
err = SSL_get_error(self->ssl, count);
|
||||
|
|
|
|||
|
|
@ -53,8 +53,9 @@ acquire_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds)
|
|||
_PyTime_timeval curtime;
|
||||
_PyTime_timeval endtime;
|
||||
|
||||
|
||||
_PyTime_gettimeofday(&endtime);
|
||||
if (microseconds > 0) {
|
||||
_PyTime_gettimeofday(&endtime);
|
||||
endtime.tv_sec += microseconds / (1000 * 1000);
|
||||
endtime.tv_usec += microseconds % (1000 * 1000);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,7 +2005,7 @@ static int
|
|||
PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
|
||||
{
|
||||
PythonCmd_ClientData *data = (PythonCmd_ClientData *)clientData;
|
||||
PyObject *self, *func, *arg, *res;
|
||||
PyObject *func, *arg, *res;
|
||||
int i, rv;
|
||||
Tcl_Obj *obj_res;
|
||||
|
||||
|
|
@ -2014,7 +2014,6 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
|
|||
/* TBD: no error checking here since we know, via the
|
||||
* Tkapp_CreateCommand() that the client data is a two-tuple
|
||||
*/
|
||||
self = data->self;
|
||||
func = data->func;
|
||||
|
||||
/* Create argument list (argv1, ..., argvN) */
|
||||
|
|
|
|||
|
|
@ -876,7 +876,6 @@ array_inplace_repeat(arrayobject *self, Py_ssize_t n)
|
|||
if (Py_SIZE(self) > 0) {
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
items = self->ob_item;
|
||||
if ((self->ob_descr->itemsize != 0) &&
|
||||
(Py_SIZE(self) > PY_SSIZE_T_MAX / self->ob_descr->itemsize)) {
|
||||
return PyErr_NoMemory();
|
||||
|
|
|
|||
|
|
@ -513,7 +513,6 @@ audioop_findfit(PyObject *self, PyObject *args)
|
|||
|
||||
best_result = result;
|
||||
best_j = 0;
|
||||
j = 0;
|
||||
|
||||
for ( j=1; j<=len1-len2; j++) {
|
||||
aj_m1 = (double)cp1[j-1];
|
||||
|
|
@ -599,7 +598,6 @@ audioop_findmax(PyObject *self, PyObject *args)
|
|||
|
||||
best_result = result;
|
||||
best_j = 0;
|
||||
j = 0;
|
||||
|
||||
for ( j=1; j<=len1-len2; j++) {
|
||||
aj_m1 = (double)cp1[j-1];
|
||||
|
|
@ -1433,7 +1431,6 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
|
|||
if ( state == Py_None ) {
|
||||
/* First time, it seems. Set defaults */
|
||||
valpred = 0;
|
||||
step = 7;
|
||||
index = 0;
|
||||
} else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) )
|
||||
return 0;
|
||||
|
|
@ -1534,7 +1531,6 @@ audioop_adpcm2lin(PyObject *self, PyObject *args)
|
|||
if ( state == Py_None ) {
|
||||
/* First time, it seems. Set defaults */
|
||||
valpred = 0;
|
||||
step = 7;
|
||||
index = 0;
|
||||
} else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) )
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ struct iso2022_config {
|
|||
|
||||
CODEC_INIT(iso2022)
|
||||
{
|
||||
const struct iso2022_designation *desig = CONFIG_DESIGNATIONS;
|
||||
const struct iso2022_designation *desig;
|
||||
for (desig = CONFIG_DESIGNATIONS; desig->mark; desig++)
|
||||
if (desig->initializer != NULL && desig->initializer() != 0)
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -483,6 +483,7 @@ multibytecodec_encode(MultibyteCodec *codec,
|
|||
return PyBytes_FromStringAndSize(NULL, 0);
|
||||
|
||||
buf.excobj = NULL;
|
||||
buf.outobj = NULL;
|
||||
buf.inbuf = buf.inbuf_top = *data;
|
||||
buf.inbuf_end = buf.inbuf_top + datalen;
|
||||
|
||||
|
|
|
|||
|
|
@ -577,7 +577,6 @@ Py_Main(int argc, wchar_t **argv)
|
|||
if ((p = Py_GETENV("PYTHONEXECUTABLE")) && *p != '\0') {
|
||||
wchar_t* buffer;
|
||||
size_t len = strlen(p);
|
||||
size_t r;
|
||||
|
||||
buffer = malloc(len * sizeof(wchar_t));
|
||||
if (buffer == NULL) {
|
||||
|
|
@ -585,7 +584,7 @@ Py_Main(int argc, wchar_t **argv)
|
|||
"not enough memory to copy PYTHONEXECUTABLE");
|
||||
}
|
||||
|
||||
r = mbstowcs(buffer, p, len);
|
||||
mbstowcs(buffer, p, len);
|
||||
Py_SetProgramName(buffer);
|
||||
/* buffer is now handed off - do not free */
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -3407,7 +3407,7 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
|
|||
goto finally;
|
||||
af = sa->sa_family;
|
||||
ap = NULL;
|
||||
al = 0;
|
||||
/* al = 0; */
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
ap = (char *)&((struct sockaddr_in *)sa)->sin_addr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue