Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cf703f0

Browse files
author
Moshe Zadka
committed
Removing warnings found by gcc -Wall
1 parent 92a6913 commit cf703f0

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

Objects/bufferobject.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ PyBuffer_FromReadWriteMemory(void *ptr, int size)
141141
PyObject *
142142
PyBuffer_New(int size)
143143
{
144+
PyObject *o;
144145
PyBufferObject * b;
145146

146147
if (size < 0) {
@@ -149,10 +150,10 @@ PyBuffer_New(int size)
149150
return NULL;
150151
}
151152
/* PyObject_New is inlined */
152-
b = (PyBufferObject *) PyObject_MALLOC(sizeof(*b) + size);
153-
if ( b == NULL )
153+
o = PyObject_MALLOC(sizeof(*b) + size);
154+
if ( o == NULL )
154155
return PyErr_NoMemory();
155-
PyObject_INIT((PyObject *)b, &PyBuffer_Type);
156+
b = (PyBufferObject *) PyObject_INIT(o, &PyBuffer_Type);
156157

157158
b->b_base = NULL;
158159
b->b_ptr = (void *)(b + 1);
@@ -162,7 +163,7 @@ PyBuffer_New(int size)
162163
b->b_hash = -1;
163164
#endif
164165

165-
return (PyObject *) b;
166+
return o;
166167
}
167168

168169
/* Methods */

Objects/object.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,10 @@ _PyTrash_deposit_object(PyObject *op)
11231123
typecode = Py_TRASHCAN_FRAME;
11241124
else if (PyTraceBack_Check(op))
11251125
typecode = Py_TRASHCAN_TRACEBACK;
1126+
else /* We have a bug here -- those are the only types in GC */ {
1127+
Py_FatalError("Type not supported in GC -- internal bug");
1128+
return; /* pacify compiler -- execution never here */
1129+
}
11261130
op->ob_refcnt = typecode;
11271131

11281132
op->ob_type = (PyTypeObject*)_PyTrash_delete_later;

0 commit comments

Comments
 (0)