]> granicus.if.org Git - python/commitdiff
Patch #100854 from jhylton: eliminate compiler warnings in pyexpat:
authorAndrew M. Kuchling <amk@amk.ca>
Wed, 12 Jul 2000 00:53:41 +0000 (00:53 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Wed, 12 Jul 2000 00:53:41 +0000 (00:53 +0000)
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.)

Modules/pyexpat.c

index e0c03f60cb50bfe34ee960442bb3504cbb55b845..f0b17c5e296a90ecbac34174e216100c5e1383a2 100644 (file)
@@ -70,34 +70,35 @@ staticforward struct HandlerInfo handler_info[64];
 
 /* Convert an array of attributes and their values into a Python dict */
 
-static PyObject *conv_atts_using_string( XML_Char **atts){
-       PyObject *attrs_obj=NULL;
-       XML_Char **attrs_p, **attrs_k;
+static PyObject *conv_atts_using_string(XML_Char **atts)
+{
+       PyObject *attrs_obj = NULL;
+       XML_Char **attrs_p, **attrs_k = NULL;
        int attrs_len;
        PyObject *rv;
 
-       if( (attrs_obj = PyDict_New()) == NULL 
+       if ((attrs_obj = PyDict_New()) == NULL
                goto finally;
-       for(attrs_len=0, attrs_p = atts; 
-           *attrs_p;
-           attrs_p++, attrs_len++) {
-               if (attrs_len%2) {
-                       rv=PyString_FromString(*attrs_p);  
+       for (attrs_len = 0, attrs_p = atts; 
+            *attrs_p;
+            attrs_p++, attrs_len++) {
+               if (attrs_len % 2) {
+                       rv = PyString_FromString(*attrs_p);  
                        if (! rv) {
                                Py_DECREF(attrs_obj);
-                               attrs_obj=NULL;
+                               attrs_obj = NULL;
                                goto finally;
                        }
-                       if (PyDict_SetItemString(
-                              attrs_obj,
-                              (char*)*attrs_k, rv) < 0){
+                       if (PyDict_SetItemString(attrs_obj,
+                                                (char*)*attrs_k, rv) < 0) {
                                Py_DECREF(attrs_obj);
-                               attrs_obj=NULL;
+                               attrs_obj = NULL;
                                goto finally;
                        }
                        Py_DECREF(rv);
                }
-               else attrs_k=attrs_p;
+               else 
+                       attrs_k = attrs_p;
        }
        finally:
        return attrs_obj;
@@ -106,7 +107,7 @@ static PyObject *conv_atts_using_string( XML_Char **atts){
 #if !(PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6)
 static PyObject *conv_atts_using_unicode( XML_Char **atts){
         PyObject *attrs_obj=NULL;
-        XML_Char **attrs_p, **attrs_k;
+        XML_Char **attrs_p, **attrs_k = NULL;
         int attrs_len;
 
         if( (attrs_obj = PyDict_New()) == NULL ) 
@@ -445,11 +446,11 @@ int readinst(char *buf, int buf_size, PyObject *meth){
        PyObject *arg=NULL;
        PyObject *bytes=NULL;
        PyObject *str=NULL;
-       int len;
+       int len = 0;
 
        UNLESS(bytes = PyInt_FromLong(buf_size)) {
                if (!PyErr_Occurred())
-               PyErr_SetNone(PyExc_EOFError);
+                       PyErr_SetNone(PyExc_EOFError);
                goto finally;
        }
 
@@ -467,9 +468,9 @@ int readinst(char *buf, int buf_size, PyObject *meth){
        UNLESS(PyString_Check( str ))
                goto finally;
 
-       len=PyString_GET_SIZE( str );
-       strncpy( buf, PyString_AsString(str), len );
-       Py_XDECREF( str );
+       len = PyString_GET_SIZE(str);
+       strncpy(buf, PyString_AsString(str), len);
+       Py_XDECREF(str);
 finally:
        return len;
 }