[Python-checkins] bpo-30860: Fix deadcode in obmalloc.c (#3499)

Victor Stinner webhook-mailer at python.org
Thu Sep 14 17:48:40 EDT 2017


https://github.com/python/cpython/commit/ccb3c7654cc3d031fb93bf443a6ef9cfb11f6b43
commit: ccb3c7654cc3d031fb93bf443a6ef9cfb11f6b43
branch: master
author: Victor Stinner <victor.stinner at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017-09-14T14:48:37-07:00
summary:

bpo-30860: Fix deadcode in obmalloc.c (#3499)

Fix Coverity CID 1417587: _PyMem_Initialize() contains code which is
never executed.

Replace the runtime check with a build assertion.

files:
M Objects/obmalloc.c

diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 57edf97e206..f2651d7574b 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -297,9 +297,9 @@ _PyMem_Initialize(struct _pymem_runtime_state *state)
     state->allocators.obj = _pyobject;
 
 #ifdef WITH_PYMALLOC
+    Py_BUILD_ASSERT(NB_SMALL_SIZE_CLASSES == 64);
+
     for (int i = 0; i < 8; i++) {
-        if (NB_SMALL_SIZE_CLASSES <= i * 8)
-            break;
         for (int j = 0; j < 8; j++) {
             int x = i * 8 + j;
             poolp *addr = &(state->usedpools[2*(x)]);



More information about the Python-checkins mailing list