From 1a784e1afbcb2b9951e4162249e7aaabbd2276c6 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Tue, 30 Jan 2018 17:32:12 -0800 Subject: [PATCH] PYTHON-1466 Silence minor complaints from Coverity Remove useless NULL check as GETSTATE cannot return NULL after successful initialization. --- bson/_cbsonmodule.c | 4 ++-- pymongo/_cmessagemodule.c | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/bson/_cbsonmodule.c b/bson/_cbsonmodule.c index a06729740..dbd655d7b 100644 --- a/bson/_cbsonmodule.c +++ b/bson/_cbsonmodule.c @@ -2642,8 +2642,8 @@ static PyObject* _elements_to_dict(PyObject* self, const char* string, return NULL; } while (position < max) { - PyObject* name; - PyObject* value; + PyObject* name = NULL; + PyObject* value = NULL; int new_position; new_position = _element_to_dict( diff --git a/pymongo/_cmessagemodule.c b/pymongo/_cmessagemodule.c index 0f1a4fd1b..17de8b266 100644 --- a/pymongo/_cmessagemodule.c +++ b/pymongo/_cmessagemodule.c @@ -1293,7 +1293,6 @@ init_cmessage(void) PyObject *_cbson = NULL; PyObject *c_api_object = NULL; PyObject *m = NULL; - struct module_state *state; /* Store a reference to the _cbson module since it's needed to call some * of its functions @@ -1330,11 +1329,7 @@ init_cmessage(void) goto fail; } - state = GETSTATE(m); - if (state == NULL) { - goto fail; - } - state->_cbson = _cbson; + GETSTATE(m)->_cbson = _cbson; Py_DECREF(c_api_object);