From 59977790938df153aa1a3883c67124c47d2ee4d2 Mon Sep 17 00:00:00 2001 From: eamanu Date: Tue, 7 May 2019 21:24:27 -0300 Subject: [PATCH 1/2] Avoid warning of unused variables When run ```./configure && make -j4``` there are two warnings on Object/dictobject.c file about ix and hash variable are not used. Zachary Ware make me note that when _PyObject_ASSERT is call and NDEBUG is defined that expand to ((void)0). So this PR add a #ifndef check to avoid the warnings. --- Objects/dictobject.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 9b5c0a3be9ab7aa..c14fdf9682a9ba5 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -481,20 +481,23 @@ _PyDict_CheckConsistency(PyObject *op, int check_content) PyDictKeyEntry *entries = DK_ENTRIES(keys); Py_ssize_t i; +#ifndef NDEBUG for (i=0; i < keys->dk_size; i++) { Py_ssize_t ix = dictkeys_get_index(keys, i); _PyObject_ASSERT(op, DKIX_DUMMY <= ix && ix <= usable); } - +#endif for (i=0; i < usable; i++) { PyDictKeyEntry *entry = &entries[i]; PyObject *key = entry->me_key; if (key != NULL) { if (PyUnicode_CheckExact(key)) { +#ifndef NDEBUG Py_hash_t hash = ((PyASCIIObject *)key)->hash; _PyObject_ASSERT(op, hash != -1); _PyObject_ASSERT(op, entry->me_hash == hash); +#endif } else { /* test_dict fails if PyObject_Hash() is called again */ From 8ef135ec8e1b9db8d08b5965264d6ccd987291b2 Mon Sep 17 00:00:00 2001 From: eamanu Date: Thu, 9 May 2019 21:02:10 -0300 Subject: [PATCH 2/2] Update PR according to @methane comments --- Objects/dictobject.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index c14fdf9682a9ba5..c8c88d2c0fc5c00 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -459,6 +459,7 @@ static PyObject *empty_values[1] = { NULL }; int _PyDict_CheckConsistency(PyObject *op, int check_content) { +#ifndef NDEBUG _PyObject_ASSERT(op, PyDict_Check(op)); PyDictObject *mp = (PyDictObject *)op; @@ -481,23 +482,20 @@ _PyDict_CheckConsistency(PyObject *op, int check_content) PyDictKeyEntry *entries = DK_ENTRIES(keys); Py_ssize_t i; -#ifndef NDEBUG for (i=0; i < keys->dk_size; i++) { Py_ssize_t ix = dictkeys_get_index(keys, i); _PyObject_ASSERT(op, DKIX_DUMMY <= ix && ix <= usable); } -#endif + for (i=0; i < usable; i++) { PyDictKeyEntry *entry = &entries[i]; PyObject *key = entry->me_key; if (key != NULL) { if (PyUnicode_CheckExact(key)) { -#ifndef NDEBUG Py_hash_t hash = ((PyASCIIObject *)key)->hash; _PyObject_ASSERT(op, hash != -1); _PyObject_ASSERT(op, entry->me_hash == hash); -#endif } else { /* test_dict fails if PyObject_Hash() is called again */ @@ -520,7 +518,7 @@ _PyDict_CheckConsistency(PyObject *op, int check_content) } } } - +#endif return 1; }