@@ -1170,7 +1170,7 @@ PyCPointerType_init(PyObject *self, PyObject *args, PyObject *kwds)
11701170 }
11711171 if (proto ) {
11721172 const char * current_format ;
1173- if (-1 == PyCPointerType_SetProto (st , stginfo , proto )) {
1173+ if (PyCPointerType_SetProto (st , stginfo , proto ) < 0 ) {
11741174 Py_DECREF (proto );
11751175 return -1 ;
11761176 }
@@ -1224,7 +1224,7 @@ PyCPointerType_set_type(PyTypeObject *self, PyObject *type)
12241224 return NULL ;
12251225 }
12261226
1227- if (-1 == PyCPointerType_SetProto (st , info , type )) {
1227+ if (PyCPointerType_SetProto (st , info , type ) < 0 ) {
12281228 Py_DECREF (attrdict );
12291229 return NULL ;
12301230 }
@@ -1978,12 +1978,13 @@ static PyObject *CreateSwappedType(ctypes_state *st, PyTypeObject *type,
19781978 if (!swapped_args )
19791979 return NULL ;
19801980
1981- if (st -> swapped_suffix == NULL )
1981+ if (st -> swapped_suffix == NULL ) {
19821982#ifdef WORDS_BIGENDIAN
19831983 st -> swapped_suffix = PyUnicode_InternFromString ("_le" );
19841984#else
19851985 st -> swapped_suffix = PyUnicode_InternFromString ("_be" );
19861986#endif
1987+ }
19871988 if (st -> swapped_suffix == NULL ) {
19881989 Py_DECREF (swapped_args );
19891990 return NULL ;
@@ -2558,7 +2559,7 @@ PyCFuncPtrType_init(PyObject *self, PyObject *args, PyObject *kwds)
25582559 }
25592560 stginfo -> flags |= TYPEFLAG_ISPOINTER ;
25602561
2561- if (-1 == make_funcptrtype_dict (st , attrdict , stginfo )) {
2562+ if (make_funcptrtype_dict (st , attrdict , stginfo ) < 0 ) {
25622563 Py_DECREF (attrdict );
25632564 return -1 ;
25642565 }
@@ -3042,8 +3043,9 @@ PyCData_get(ctypes_state *st, PyObject *type, GETFUNC getfunc, PyObject *src,
30423043 if (PyStgInfo_FromType (st , type , & info ) < 0 ) {
30433044 return NULL ;
30443045 }
3045- if (info && info -> getfunc && !_ctypes_simple_instance (st , type ))
3046+ if (info && info -> getfunc && !_ctypes_simple_instance (st , type )) {
30463047 return info -> getfunc (adr , size );
3048+ }
30473049 return PyCData_FromBaseObj (st , type , src , index , adr );
30483050}
30493051
@@ -3676,9 +3678,9 @@ PyCFuncPtr_FromVtblIndex(PyTypeObject *type, PyObject *args, PyObject *kwds)
36763678 paramflags = NULL ;
36773679
36783680 ctypes_state * st = GLOBAL_STATE ();
3679- if (!_validate_paramflags (st , type , paramflags ))
3681+ if (!_validate_paramflags (st , type , paramflags )) {
36803682 return NULL ;
3681-
3683+ }
36823684 self = (PyCFuncPtrObject * )_GenericPyCData_new (st , type , args , kwds );
36833685 self -> index = index + 0x1000 ;
36843686 self -> paramflags = Py_XNewRef (paramflags );
@@ -4790,8 +4792,9 @@ PyCArrayType_from_ctype(ctypes_state *st, PyObject *itemtype, Py_ssize_t length)
47904792
47914793 if (st -> array_cache == NULL ) {
47924794 st -> array_cache = PyDict_New ();
4793- if (st -> array_cache == NULL )
4795+ if (st -> array_cache == NULL ) {
47944796 return NULL ;
4797+ }
47954798 }
47964799 len = PyLong_FromSsize_t (length );
47974800 if (len == NULL )
@@ -4834,7 +4837,7 @@ PyCArrayType_from_ctype(ctypes_state *st, PyObject *itemtype, Py_ssize_t length)
48344837 Py_DECREF (key );
48354838 return NULL ;
48364839 }
4837- if (-1 == PyDict_SetItemProxy (st , st -> array_cache , key , result )) {
4840+ if (PyDict_SetItemProxy (st , st -> array_cache , key , result ) < 0 ) {
48384841 Py_DECREF (key );
48394842 Py_DECREF (result );
48404843 return NULL ;
@@ -5461,8 +5464,9 @@ cast(void *ptr, PyObject *src, PyObject *ctype)
54615464 ctypes_state * st = GLOBAL_STATE ();
54625465
54635466 CDataObject * result ;
5464- if (0 == cast_check_pointertype (st , ctype ))
5467+ if (cast_check_pointertype (st , ctype ) == 0 ) {
54655468 return NULL ;
5469+ }
54665470 result = (CDataObject * )_PyObject_CallNoArgs (ctype );
54675471 if (result == NULL )
54685472 return NULL ;
0 commit comments