diff options
author | Lisandro Dalcin <dalcinl@gmail.com> | 2022-10-17 22:42:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-17 22:42:51 +0300 |
commit | b37cfc9a7028f79025c83a9315544b22c9b43d31 (patch) | |
tree | 2bd29d6b69ddb1d7e2d0560a66e6b58665618736 | |
parent | 95009ba67a4c0e4cbe2285d59cde5029574c6fc3 (diff) | |
download | cython-b37cfc9a7028f79025c83a9315544b22c9b43d31.tar.gz |
Fix various clang warnings (#5086)
* Fix clang -Wcomma
* Fix clang -Wextra-semi-stmt
* Fix clang -Wconditional-uninitialized
* Fix clang -Wunreachable-code-return
-rw-r--r-- | Cython/Compiler/Code.py | 2 | ||||
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 4 | ||||
-rw-r--r-- | Cython/Compiler/PyrexTypes.py | 2 | ||||
-rw-r--r-- | Cython/Utility/Exceptions.c | 6 | ||||
-rw-r--r-- | Cython/Utility/ObjectHandling.c | 21 |
5 files changed, 16 insertions, 19 deletions
diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index 45c5a325c..d0b4756e5 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -1559,7 +1559,7 @@ class GlobalState(object): init_globals = self.parts['init_globals'] init_globals.putln( - "if (__Pyx_InitStrings(%s) < 0) %s;" % ( + "if (__Pyx_InitStrings(%s) < 0) %s" % ( Naming.stringtab_cname, init_globals.error_goto(self.module_pos))) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index bb5aa66fb..56845330d 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -2491,7 +2491,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): if Options.generate_cleanup_code: code.globalstate.use_utility_code( UtilityCode.load_cached("RegisterModuleCleanup", "ModuleSetupCode.c")) - code.putln("if (__Pyx_RegisterCleanup()) %s;" % code.error_goto(self.pos)) + code.putln("if (__Pyx_RegisterCleanup()) %s" % code.error_goto(self.pos)) code.put_goto(code.return_label) code.put_label(code.error_label) @@ -2835,7 +2835,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.error_goto_if_null(Naming.cython_runtime_cname, self.pos))) code.put_incref(Naming.cython_runtime_cname, py_object_type, nanny=False) code.putln( - 'if (PyObject_SetAttrString(%s, "__builtins__", %s) < 0) %s;' % ( + 'if (PyObject_SetAttrString(%s, "__builtins__", %s) < 0) %s' % ( env.module_cname, Naming.builtins_cname, code.error_goto(self.pos))) diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index dcb51fe34..922c39367 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -1297,7 +1297,7 @@ class BuiltinObjectType(PyObjectType): name = '"%s"' % self.name # avoid wasting too much space but limit number of different format strings space_for_name = (len(self.name) // 16 + 1) * 16 - error = '(PyErr_Format(PyExc_TypeError, "Expected %%.%ds, got %%.200s", %s, Py_TYPE(%s)->tp_name), 0)' % ( + error = '((void)PyErr_Format(PyExc_TypeError, "Expected %%.%ds, got %%.200s", %s, Py_TYPE(%s)->tp_name), 0)' % ( space_for_name, name, arg) return check + '||' + error diff --git a/Cython/Utility/Exceptions.c b/Cython/Utility/Exceptions.c index 7896d40dc..2c87f720c 100644 --- a/Cython/Utility/Exceptions.c +++ b/Cython/Utility/Exceptions.c @@ -600,10 +600,8 @@ static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); -#ifdef _MSC_VER - /* arbitrary, to suppress warning */ - else state = (PyGILState_STATE)-1; -#endif + /* initalize to suppress warning */ + else state = (PyGILState_STATE)0; #endif __Pyx_PyThreadState_assign __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); diff --git a/Cython/Utility/ObjectHandling.c b/Cython/Utility/ObjectHandling.c index 864b658f7..8b572ca6f 100644 --- a/Cython/Utility/ObjectHandling.c +++ b/Cython/Utility/ObjectHandling.c @@ -72,10 +72,9 @@ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; - } else { - return __Pyx_IterFinish(); } - return 0; + + return __Pyx_IterFinish(); } /////////////// UnpackTuple2.proto /////////////// @@ -285,7 +284,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* k #if CYTHON_USE_TYPE_SLOTS static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { - PyObject *runerr; + PyObject *runerr = NULL; Py_ssize_t key_value; PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; if (unlikely(!(m && m->sq_item))) { @@ -1169,18 +1168,18 @@ static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name) { //@substitute: naming #if CYTHON_USE_DICT_VERSIONS -#define __Pyx_GetModuleGlobalName(var, name) { \ +#define __Pyx_GetModuleGlobalName(var, name) do { \ static PY_UINT64_T __pyx_dict_version = 0; \ static PyObject *__pyx_dict_cached_value = NULL; \ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION($moddict_cname))) ? \ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) : \ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value); \ -} -#define __Pyx_GetModuleGlobalNameUncached(var, name) { \ +} while(0) +#define __Pyx_GetModuleGlobalNameUncached(var, name) do { \ PY_UINT64_T __pyx_dict_version; \ PyObject *__pyx_dict_cached_value; \ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value); \ -} +} while(0) static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); /*proto*/ #else #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) @@ -1668,11 +1667,11 @@ static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* if (flag == METH_O) { return (*(cfunc->func))(self, arg); } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) { - if (PY_VERSION_HEX >= 0x030700A0) { + #if PY_VERSION_HEX >= 0x030700A0 return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1); - } else { + #else return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); - } + #endif } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) { return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); } |