]> granicus.if.org Git - python/commitdiff
bpo-30860: Fix deadcode in obmalloc.c (#3499)
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 14 Sep 2017 21:48:37 +0000 (14:48 -0700)
committerGitHub <noreply@github.com>
Thu, 14 Sep 2017 21:48:37 +0000 (14:48 -0700)
Fix Coverity CID 1417587: _PyMem_Initialize() contains code which is
never executed.

Replace the runtime check with a build assertion.

Objects/obmalloc.c

index 57edf97e2064e51431d2bc5cc3b2d3e85274b8eb..f2651d7574b20f7b36665cfae05e84af404ef363 100644 (file)
@@ -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)]);