Commit a4e75d74 authored by Andrew M. Kuchling's avatar Andrew M. Kuchling

Patch #100854 from jhylton: eliminate compiler warnings in pyexpat:

	The first two warnings seem harmless enough,
	but the last one looks like a potential bug: an
	uninitialized int is returned on error. (I also
	ended up reformatting some of the code,
	because it was hard to read.)
parent 9e3d73af
...@@ -70,34 +70,35 @@ staticforward struct HandlerInfo handler_info[64]; ...@@ -70,34 +70,35 @@ staticforward struct HandlerInfo handler_info[64];
/* Convert an array of attributes and their values into a Python dict */ /* Convert an array of attributes and their values into a Python dict */
static PyObject *conv_atts_using_string( XML_Char **atts){ static PyObject *conv_atts_using_string(XML_Char **atts)
PyObject *attrs_obj=NULL; {
XML_Char **attrs_p, **attrs_k; PyObject *attrs_obj = NULL;
XML_Char **attrs_p, **attrs_k = NULL;
int attrs_len; int attrs_len;
PyObject *rv; PyObject *rv;
if( (attrs_obj = PyDict_New()) == NULL ) if ((attrs_obj = PyDict_New()) == NULL)
goto finally; goto finally;
for(attrs_len=0, attrs_p = atts; for (attrs_len = 0, attrs_p = atts;
*attrs_p; *attrs_p;
attrs_p++, attrs_len++) { attrs_p++, attrs_len++) {
if (attrs_len%2) { if (attrs_len % 2) {
rv=PyString_FromString(*attrs_p); rv = PyString_FromString(*attrs_p);
if (! rv) { if (! rv) {
Py_DECREF(attrs_obj); Py_DECREF(attrs_obj);
attrs_obj=NULL; attrs_obj = NULL;
goto finally; goto finally;
} }
if (PyDict_SetItemString( if (PyDict_SetItemString(attrs_obj,
attrs_obj, (char*)*attrs_k, rv) < 0) {
(char*)*attrs_k, rv) < 0){
Py_DECREF(attrs_obj); Py_DECREF(attrs_obj);
attrs_obj=NULL; attrs_obj = NULL;
goto finally; goto finally;
} }
Py_DECREF(rv); Py_DECREF(rv);
} }
else attrs_k=attrs_p; else
attrs_k = attrs_p;
} }
finally: finally:
return attrs_obj; return attrs_obj;
...@@ -106,7 +107,7 @@ static PyObject *conv_atts_using_string( XML_Char **atts){ ...@@ -106,7 +107,7 @@ static PyObject *conv_atts_using_string( XML_Char **atts){
#if !(PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6) #if !(PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6)
static PyObject *conv_atts_using_unicode( XML_Char **atts){ static PyObject *conv_atts_using_unicode( XML_Char **atts){
PyObject *attrs_obj=NULL; PyObject *attrs_obj=NULL;
XML_Char **attrs_p, **attrs_k; XML_Char **attrs_p, **attrs_k = NULL;
int attrs_len; int attrs_len;
if( (attrs_obj = PyDict_New()) == NULL ) if( (attrs_obj = PyDict_New()) == NULL )
...@@ -445,7 +446,7 @@ int readinst(char *buf, int buf_size, PyObject *meth){ ...@@ -445,7 +446,7 @@ int readinst(char *buf, int buf_size, PyObject *meth){
PyObject *arg=NULL; PyObject *arg=NULL;
PyObject *bytes=NULL; PyObject *bytes=NULL;
PyObject *str=NULL; PyObject *str=NULL;
int len; int len = 0;
UNLESS(bytes = PyInt_FromLong(buf_size)) { UNLESS(bytes = PyInt_FromLong(buf_size)) {
if (!PyErr_Occurred()) if (!PyErr_Occurred())
...@@ -467,9 +468,9 @@ int readinst(char *buf, int buf_size, PyObject *meth){ ...@@ -467,9 +468,9 @@ int readinst(char *buf, int buf_size, PyObject *meth){
UNLESS(PyString_Check( str )) UNLESS(PyString_Check( str ))
goto finally; goto finally;
len=PyString_GET_SIZE( str ); len = PyString_GET_SIZE(str);
strncpy( buf, PyString_AsString(str), len ); strncpy(buf, PyString_AsString(str), len);
Py_XDECREF( str ); Py_XDECREF(str);
finally: finally:
return len; return len;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment