Issue #22463: Backport compiler warning fixes and workarounds
* 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.
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 636d178..738e613 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -2256,7 +2256,7 @@
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 {
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index 9e97d1b..c4e3895 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -239,7 +239,7 @@
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;
}
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 82cb28d..801f286 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -149,7 +149,7 @@
/* 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;
}
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 654d2fe..41bb074 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -107,7 +107,7 @@
/* 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 @@
/* 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;
}
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 0b60ca3..c1a99ab 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -20,7 +20,7 @@
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 {
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index f2db6da..1a04b78 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -88,7 +88,7 @@
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 @@
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 @@
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 @@
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';
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index cae5118..272a283 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -791,7 +791,7 @@
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);
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 0b81a3c..ca6628e 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -347,7 +347,7 @@
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;