@@ -1170,7 +1170,7 @@ PyCPointerType_init(PyObject *self, PyObject *args, PyObject *kwds)
1170
1170
}
1171
1171
if (proto ) {
1172
1172
const char * current_format ;
1173
- if (-1 == PyCPointerType_SetProto (st , stginfo , proto )) {
1173
+ if (PyCPointerType_SetProto (st , stginfo , proto ) < 0 ) {
1174
1174
Py_DECREF (proto );
1175
1175
return -1 ;
1176
1176
}
@@ -1224,7 +1224,7 @@ PyCPointerType_set_type(PyTypeObject *self, PyObject *type)
1224
1224
return NULL ;
1225
1225
}
1226
1226
1227
- if (-1 == PyCPointerType_SetProto (st , info , type )) {
1227
+ if (PyCPointerType_SetProto (st , info , type ) < 0 ) {
1228
1228
Py_DECREF (attrdict );
1229
1229
return NULL ;
1230
1230
}
@@ -1978,12 +1978,13 @@ static PyObject *CreateSwappedType(ctypes_state *st, PyTypeObject *type,
1978
1978
if (!swapped_args )
1979
1979
return NULL ;
1980
1980
1981
- if (st -> swapped_suffix == NULL )
1981
+ if (st -> swapped_suffix == NULL ) {
1982
1982
#ifdef WORDS_BIGENDIAN
1983
1983
st -> swapped_suffix = PyUnicode_InternFromString ("_le" );
1984
1984
#else
1985
1985
st -> swapped_suffix = PyUnicode_InternFromString ("_be" );
1986
1986
#endif
1987
+ }
1987
1988
if (st -> swapped_suffix == NULL ) {
1988
1989
Py_DECREF (swapped_args );
1989
1990
return NULL ;
@@ -2558,7 +2559,7 @@ PyCFuncPtrType_init(PyObject *self, PyObject *args, PyObject *kwds)
2558
2559
}
2559
2560
stginfo -> flags |= TYPEFLAG_ISPOINTER ;
2560
2561
2561
- if (-1 == make_funcptrtype_dict (st , attrdict , stginfo )) {
2562
+ if (make_funcptrtype_dict (st , attrdict , stginfo ) < 0 ) {
2562
2563
Py_DECREF (attrdict );
2563
2564
return -1 ;
2564
2565
}
@@ -3042,8 +3043,9 @@ PyCData_get(ctypes_state *st, PyObject *type, GETFUNC getfunc, PyObject *src,
3042
3043
if (PyStgInfo_FromType (st , type , & info ) < 0 ) {
3043
3044
return NULL ;
3044
3045
}
3045
- if (info && info -> getfunc && !_ctypes_simple_instance (st , type ))
3046
+ if (info && info -> getfunc && !_ctypes_simple_instance (st , type )) {
3046
3047
return info -> getfunc (adr , size );
3048
+ }
3047
3049
return PyCData_FromBaseObj (st , type , src , index , adr );
3048
3050
}
3049
3051
@@ -3676,9 +3678,9 @@ PyCFuncPtr_FromVtblIndex(PyTypeObject *type, PyObject *args, PyObject *kwds)
3676
3678
paramflags = NULL ;
3677
3679
3678
3680
ctypes_state * st = GLOBAL_STATE ();
3679
- if (!_validate_paramflags (st , type , paramflags ))
3681
+ if (!_validate_paramflags (st , type , paramflags )) {
3680
3682
return NULL ;
3681
-
3683
+ }
3682
3684
self = (PyCFuncPtrObject * )_GenericPyCData_new (st , type , args , kwds );
3683
3685
self -> index = index + 0x1000 ;
3684
3686
self -> paramflags = Py_XNewRef (paramflags );
@@ -4790,8 +4792,9 @@ PyCArrayType_from_ctype(ctypes_state *st, PyObject *itemtype, Py_ssize_t length)
4790
4792
4791
4793
if (st -> array_cache == NULL ) {
4792
4794
st -> array_cache = PyDict_New ();
4793
- if (st -> array_cache == NULL )
4795
+ if (st -> array_cache == NULL ) {
4794
4796
return NULL ;
4797
+ }
4795
4798
}
4796
4799
len = PyLong_FromSsize_t (length );
4797
4800
if (len == NULL )
@@ -4834,7 +4837,7 @@ PyCArrayType_from_ctype(ctypes_state *st, PyObject *itemtype, Py_ssize_t length)
4834
4837
Py_DECREF (key );
4835
4838
return NULL ;
4836
4839
}
4837
- if (-1 == PyDict_SetItemProxy (st , st -> array_cache , key , result )) {
4840
+ if (PyDict_SetItemProxy (st , st -> array_cache , key , result ) < 0 ) {
4838
4841
Py_DECREF (key );
4839
4842
Py_DECREF (result );
4840
4843
return NULL ;
@@ -5461,8 +5464,9 @@ cast(void *ptr, PyObject *src, PyObject *ctype)
5461
5464
ctypes_state * st = GLOBAL_STATE ();
5462
5465
5463
5466
CDataObject * result ;
5464
- if (0 == cast_check_pointertype (st , ctype ))
5467
+ if (cast_check_pointertype (st , ctype ) == 0 ) {
5465
5468
return NULL ;
5469
+ }
5466
5470
result = (CDataObject * )_PyObject_CallNoArgs (ctype );
5467
5471
if (result == NULL )
5468
5472
return NULL ;
0 commit comments