Skip to content

Commit

Permalink
pythongh-94673: Fix compiler warning in typeobject.c
Browse files Browse the repository at this point in the history
static_builtin_index_is_set() is only used in asserts; inline it to avoid compiler warnings.
  • Loading branch information
erlend-aasland committed Apr 17, 2024
1 parent 1aa8bbe commit 9ad94d3
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,10 @@ type_from_ref(PyObject *ref)

/* helpers for for static builtin types */

static inline int
static_builtin_index_is_set(PyTypeObject *self)
{
return self->tp_subclasses != NULL;
}

static inline size_t
static_builtin_index_get(PyTypeObject *self)
{
assert(static_builtin_index_is_set(self));
assert(self->tp_subclasses != NULL);
/* We store a 1-based index so 0 can mean "not initialized". */
return (size_t)self->tp_subclasses - 1;
}
Expand Down Expand Up @@ -163,7 +157,7 @@ static void
static_builtin_state_init(PyInterpreterState *interp, PyTypeObject *self)
{
if (_Py_IsMainInterpreter(interp)) {
assert(!static_builtin_index_is_set(self));
assert(self->tp_subclasses == NULL);
static_builtin_index_set(self, interp->types.num_builtins_initialized);
}
else {
Expand Down

0 comments on commit 9ad94d3

Please sign in to comment.