]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #22463: Backport compiler warning fixes and workarounds
authorMartin Panter <vadmium+py@gmail.com>
Tue, 21 Jun 2016 23:58:05 +0000 (23:58 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Tue, 21 Jun 2016 23:58:05 +0000 (23:58 +0000)
* Set but unused variable in Parser/pgen.c in non-debug builds. Patch by
  Christian Heimes.
* Unused static function in Modules/readline.c. Patch by Georg Brandl.
* main_window unused in Modules/tkappinit.c. Patch by Gregory P. Smith.
* Dead assignment in Modules/_ctypes/cfield.c. Extracted from patch by Brett
  Cannon.
* Expression result unused in PyObject_INIT macro expansions. Based on
  patches by Christian Heimes.
* Load expat_config.h and therefore pyconfig.h before C stdlib headers are
  loaded. This silences pre-processor warnings including '_POSIX_C_SOURCE
  redefined'. Extracted from patch by Christian Heimes.

14 files changed:
Modules/_ctypes/cfield.c
Modules/datetimemodule.c
Modules/expat/xmlparse.c
Modules/readline.c
Modules/tkappinit.c
Objects/classobject.c
Objects/complexobject.c
Objects/floatobject.c
Objects/intobject.c
Objects/methodobject.c
Objects/stringobject.c
Objects/typeobject.c
Objects/unicodeobject.c
Parser/pgen.c

index 75f65a1050d81b658fb352fcc06069dbdcc8e0f8..7fe984d86e8a37179bd6aeec32809d8bca8bf392 100644 (file)
@@ -48,7 +48,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;
@@ -102,7 +102,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
index e7fd3495087b9d8c6c09ce8201ce063bedf04f2a..45736376d14c36a114ffa3153a05473fa412f426 100644 (file)
@@ -613,7 +613,7 @@ time_alloc(PyTypeObject *type, Py_ssize_t aware)
                 sizeof(_PyDateTime_BaseTime));
     if (self == NULL)
         return (PyObject *)PyErr_NoMemory();
-    PyObject_INIT(self, type);
+    (void)PyObject_INIT(self, type);
     return self;
 }
 
@@ -628,7 +628,7 @@ datetime_alloc(PyTypeObject *type, Py_ssize_t aware)
                 sizeof(_PyDateTime_BaseDateTime));
     if (self == NULL)
         return (PyObject *)PyErr_NoMemory();
-    PyObject_INIT(self, type);
+    (void)PyObject_INIT(self, type);
     return self;
 }
 
index 6a615082e115eda4c42c9e7610b358d32d03d50b..412838794d703b18a02f8526699ec4e5cf1c81d9 100644 (file)
@@ -2,12 +2,6 @@
    See the file COPYING for copying permission.
 */
 
-#include <stddef.h>
-#include <string.h>                     /* memset(), memcpy() */
-#include <assert.h>
-#include <limits.h>                     /* UINT_MAX */
-#include <time.h>                       /* time() */
-
 #define XML_BUILDING_EXPAT 1
 
 #ifdef COMPILED_FROM_DSP
 #include <expat_config.h>
 #endif /* ndef COMPILED_FROM_DSP */
 
+#include <stddef.h>
+#include <string.h>                     /* memset(), memcpy() */
+#include <assert.h>
+#include <limits.h>                     /* UINT_MAX */
+#include <time.h>                       /* time() */
+
 #include "ascii.h"
 #include "expat.h"
 
index 1600cd3dd91bc407b3d14c6191cdcec867034851..bfb5d76172cf09f0b719a4a402481595b4aa373c 100644 (file)
@@ -66,10 +66,11 @@ static const char libedit_version_tag[] = "EditLine wrapper";
 static int libedit_history_start = 0;
 #endif /* __APPLE__ */
 
+#ifdef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK
 static void
 on_completion_display_matches_hook(char **matches,
                                    int num_matches, int max_length);
-
+#endif
 
 /* Memory allocated for rl_completer_word_break_characters
    (see issue #17289 for the motivation). */
@@ -774,6 +775,7 @@ on_pre_input_hook()
 
 /* C function to call the Python completion_display_matches */
 
+#ifdef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK
 static void
 on_completion_display_matches_hook(char **matches,
                                    int num_matches, int max_length)
@@ -874,6 +876,7 @@ on_completion(const char *text, int state)
     }
     return result;
 }
+#endif
 
 
 /* A more flexible constructor that saves the "begidx" and "endidx"
index c1f97b0a4077d1fea0deb32f9d956a4a0302c2a8..2ed85949cba034c985ba5bd5b9c31931041f59b6 100644 (file)
@@ -26,7 +26,9 @@ static int tk_load_failed;
 int
 Tcl_AppInit(Tcl_Interp *interp)
 {
+#ifdef WITH_MOREBUTTONS
     Tk_Window main_window;
+#endif
     const char *_tkinter_skip_tk_init;
 #ifdef TKINTER_PROTECT_LOADTK
     const char *_tkinter_tk_failed;
@@ -111,7 +113,11 @@ Tcl_AppInit(Tcl_Interp *interp)
         return TCL_ERROR;
     }
 
+#ifdef WITH_MOREBUTTONS
     main_window = Tk_MainWindow(interp);
+#else
+    Tk_MainWindow(interp);
+#endif
 
 #ifdef TK_AQUA
     TkMacOSXInitAppleEvents(interp);
index 636d17831d15b7996ef7db68b710dcfb2f9c3581..738e613c836ca55a50d73fb73ef75b2a33a89282 100644 (file)
@@ -2256,7 +2256,7 @@ PyMethod_New(PyObject *func, PyObject *self, PyObject *klass)
     im = free_list;
     if (im != NULL) {
         free_list = (PyMethodObject *)(im->im_self);
-        PyObject_INIT(im, &PyMethod_Type);
+        (void)PyObject_INIT(im, &PyMethod_Type);
         numfree--;
     }
     else {
index 9e97d1b3d41d63374c190b35a2b5de79672cb208..c4e3895eadb59a20ed192cec9deaf0ba7e68cfc7 100644 (file)
@@ -239,7 +239,7 @@ PyComplex_FromCComplex(Py_complex cval)
     op = (PyComplexObject *) PyObject_MALLOC(sizeof(PyComplexObject));
     if (op == NULL)
         return PyErr_NoMemory();
-    PyObject_INIT(op, &PyComplex_Type);
+    (void)PyObject_INIT(op, &PyComplex_Type);
     op->cval = cval;
     return (PyObject *) op;
 }
index 82cb28d33f84fa1ff2151da30970bc6678d21102..801f286e6a4c78c12ee3c7b3188fc11493b7a2da 100644 (file)
@@ -149,7 +149,7 @@ PyFloat_FromDouble(double fval)
     /* Inline PyObject_New */
     op = free_list;
     free_list = (PyFloatObject *)Py_TYPE(op);
-    PyObject_INIT(op, &PyFloat_Type);
+    (void)PyObject_INIT(op, &PyFloat_Type);
     op->ob_fval = fval;
     return (PyObject *) op;
 }
index 654d2fe120ecd84f28abdce1f7dfa16548af4e9c..41bb074530f17635398bd7bb7f6e236574942829 100644 (file)
@@ -107,7 +107,7 @@ PyInt_FromLong(long ival)
     /* Inline PyObject_New */
     v = free_list;
     free_list = (PyIntObject *)Py_TYPE(v);
-    PyObject_INIT(v, &PyInt_Type);
+    (void)PyObject_INIT(v, &PyInt_Type);
     v->ob_ival = ival;
     return (PyObject *) v;
 }
@@ -1466,7 +1466,7 @@ _PyInt_Init(void)
         /* PyObject_New is inlined */
         v = free_list;
         free_list = (PyIntObject *)Py_TYPE(v);
-        PyObject_INIT(v, &PyInt_Type);
+        (void)PyObject_INIT(v, &PyInt_Type);
         v->ob_ival = ival;
         small_ints[ival + NSMALLNEGINTS] = v;
     }
index 0b60ca3ce8c7e3bb0d64938ed1964c066269aebb..c1a99ab26874a360384d5099fe52f6df5ebb2796 100644 (file)
@@ -20,7 +20,7 @@ PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module)
     op = free_list;
     if (op != NULL) {
         free_list = (PyCFunctionObject *)(op->m_self);
-        PyObject_INIT(op, &PyCFunction_Type);
+        (void)PyObject_INIT(op, &PyCFunction_Type);
         numfree--;
     }
     else {
index f2db6da65aa4e8c35779a087e354aa28d210c6f9..1a04b787b3b79193d42b0c2664aa6f64352f0272 100644 (file)
@@ -88,7 +88,7 @@ PyString_FromStringAndSize(const char *str, Py_ssize_t size)
     op = (PyStringObject *)PyObject_MALLOC(PyStringObject_SIZE + size);
     if (op == NULL)
         return PyErr_NoMemory();
-    PyObject_INIT_VAR(op, &PyString_Type, size);
+    (void)PyObject_INIT_VAR(op, &PyString_Type, size);
     op->ob_shash = -1;
     op->ob_sstate = SSTATE_NOT_INTERNED;
     if (str != NULL)
@@ -143,7 +143,7 @@ PyString_FromString(const char *str)
     op = (PyStringObject *)PyObject_MALLOC(PyStringObject_SIZE + size);
     if (op == NULL)
         return PyErr_NoMemory();
-    PyObject_INIT_VAR(op, &PyString_Type, size);
+    (void)PyObject_INIT_VAR(op, &PyString_Type, size);
     op->ob_shash = -1;
     op->ob_sstate = SSTATE_NOT_INTERNED;
     Py_MEMCPY(op->ob_sval, str, size+1);
@@ -1061,7 +1061,7 @@ string_concat(register PyStringObject *a, register PyObject *bb)
     op = (PyStringObject *)PyObject_MALLOC(PyStringObject_SIZE + size);
     if (op == NULL)
         return PyErr_NoMemory();
-    PyObject_INIT_VAR(op, &PyString_Type, size);
+    (void)PyObject_INIT_VAR(op, &PyString_Type, size);
     op->ob_shash = -1;
     op->ob_sstate = SSTATE_NOT_INTERNED;
     Py_MEMCPY(op->ob_sval, a->ob_sval, Py_SIZE(a));
@@ -1103,7 +1103,7 @@ string_repeat(register PyStringObject *a, register Py_ssize_t n)
     op = (PyStringObject *)PyObject_MALLOC(PyStringObject_SIZE + nbytes);
     if (op == NULL)
         return PyErr_NoMemory();
-    PyObject_INIT_VAR(op, &PyString_Type, size);
+    (void)PyObject_INIT_VAR(op, &PyString_Type, size);
     op->ob_shash = -1;
     op->ob_sstate = SSTATE_NOT_INTERNED;
     op->ob_sval[size] = '\0';
index cae511897dbbc1457a847514b87c9212e823737d..272a283b3e1adaba6d02831c562e7ed2c3948c85 100644 (file)
@@ -791,7 +791,7 @@ PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
         Py_INCREF(type);
 
     if (type->tp_itemsize == 0)
-        PyObject_INIT(obj, type);
+        (void)PyObject_INIT(obj, type);
     else
         (void) PyObject_INIT_VAR((PyVarObject *)obj, type, nitems);
 
index 0b81a3cbf6536204c4eaf7567785c886c7e6d7b7..ca6628e2eaf7a98f25ce99e889db43fb51bab901 100644 (file)
@@ -347,7 +347,7 @@ PyUnicodeObject *_PyUnicode_New(Py_ssize_t length)
             size_t new_size = sizeof(Py_UNICODE) * ((size_t)length + 1);
             unicode->str = (Py_UNICODE*) PyObject_MALLOC(new_size);
         }
-        PyObject_INIT(unicode, &PyUnicode_Type);
+        (void)PyObject_INIT(unicode, &PyUnicode_Type);
     }
     else {
         size_t new_size;
index beaf53be0bdb345af413f808e3daa036374a4b58..b2f84709fc42c6cf7fa0800d459b1f0393ba9632 100644 (file)
@@ -283,6 +283,7 @@ compile_atom(labellist *ll, nfa *nf, node *n, int *pa, int *pb)
 
     REQ(n, ATOM);
     i = n->n_nchildren;
+    (void)i; /* Don't warn about set but unused */
     REQN(i, 1);
     n = n->n_child;
     if (n->n_type == LPAR) {