Skip to content

Commit d3afe78

Browse files
committed
Silence expression result unused warnings with clang.
The PyObject_INIT() macros returns obj: ../cpython/Objects/methodobject.c:32:23: warning: expression result unused [-Wunused-value] PyObject_INIT(op, &PyCFunction_Type); ^~ ../cpython/Include/objimpl.h:139:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ 1 warning generated.
1 parent 47f02e5 commit d3afe78

7 files changed

Lines changed: 9 additions & 9 deletions

File tree

Objects/bytesobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ PyBytes_FromStringAndSize(const char *str, Py_ssize_t size)
107107
op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + size);
108108
if (op == NULL)
109109
return PyErr_NoMemory();
110-
PyObject_INIT_VAR(op, &PyBytes_Type, size);
110+
(void)PyObject_INIT_VAR(op, &PyBytes_Type, size);
111111
op->ob_shash = -1;
112112
if (str != NULL)
113113
Py_MEMCPY(op->ob_sval, str, size);
@@ -155,7 +155,7 @@ PyBytes_FromString(const char *str)
155155
op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + size);
156156
if (op == NULL)
157157
return PyErr_NoMemory();
158-
PyObject_INIT_VAR(op, &PyBytes_Type, size);
158+
(void)PyObject_INIT_VAR(op, &PyBytes_Type, size);
159159
op->ob_shash = -1;
160160
Py_MEMCPY(op->ob_sval, str, size+1);
161161
/* share short strings */
@@ -749,7 +749,7 @@ bytes_repeat(PyBytesObject *a, Py_ssize_t n)
749749
op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + nbytes);
750750
if (op == NULL)
751751
return PyErr_NoMemory();
752-
PyObject_INIT_VAR(op, &PyBytes_Type, size);
752+
(void)PyObject_INIT_VAR(op, &PyBytes_Type, size);
753753
op->ob_shash = -1;
754754
op->ob_sval[size] = '\0';
755755
if (Py_SIZE(a) == 1 && n > 0) {

Objects/classobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ PyMethod_New(PyObject *func, PyObject *self)
5252
im = free_list;
5353
if (im != NULL) {
5454
free_list = (PyMethodObject *)(im->im_self);
55-
PyObject_INIT(im, &PyMethod_Type);
55+
(void)PyObject_INIT(im, &PyMethod_Type);
5656
numfree--;
5757
}
5858
else {

Objects/complexobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ PyComplex_FromCComplex(Py_complex cval)
217217
op = (PyComplexObject *) PyObject_MALLOC(sizeof(PyComplexObject));
218218
if (op == NULL)
219219
return PyErr_NoMemory();
220-
PyObject_INIT(op, &PyComplex_Type);
220+
(void)PyObject_INIT(op, &PyComplex_Type);
221221
op->cval = cval;
222222
return (PyObject *) op;
223223
}

Objects/floatobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ PyFloat_FromDouble(double fval)
119119
return PyErr_NoMemory();
120120
}
121121
/* Inline PyObject_New */
122-
PyObject_INIT(op, &PyFloat_Type);
122+
(void)PyObject_INIT(op, &PyFloat_Type);
123123
op->ob_fval = fval;
124124
return (PyObject *) op;
125125
}

Objects/longobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5089,7 +5089,7 @@ _PyLong_Init(void)
50895089
assert(v->ob_digit[0] == abs(ival));
50905090
}
50915091
else {
5092-
PyObject_INIT(v, &PyLong_Type);
5092+
(void)PyObject_INIT(v, &PyLong_Type);
50935093
}
50945094
Py_SIZE(v) = size;
50955095
v->ob_digit[0] = abs(ival);

Objects/methodobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module)
2929
op = free_list;
3030
if (op != NULL) {
3131
free_list = (PyCFunctionObject *)(op->m_self);
32-
PyObject_INIT(op, &PyCFunction_Type);
32+
(void)PyObject_INIT(op, &PyCFunction_Type);
3333
numfree--;
3434
}
3535
else {

Objects/typeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
787787
Py_INCREF(type);
788788

789789
if (type->tp_itemsize == 0)
790-
PyObject_INIT(obj, type);
790+
(void)PyObject_INIT(obj, type);
791791
else
792792
(void) PyObject_INIT_VAR((PyVarObject *)obj, type, nitems);
793793

0 commit comments

Comments
 (0)