10000 un-Yoda cond, curly braces · python/cpython@9342336 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9342336

Browse files
committed
un-Yoda cond, curly braces
1 parent b2adc1f commit 9342336

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

Modules/_ctypes/callproc.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ _ctypes_get_errobj(ctypes_state *st, int **pspace)
164164
}
165165
if (st->error_object_name == NULL) {
166166
st->error_object_name = PyUnicode_InternFromString("ctypes.error_object");
167-
if (st->error_object_name == NULL)
167+
if (st->error_object_name == NULL) {
168168
return NULL;
169+
}
169170
}
170171
if (PyDict_GetItemRef(dict, st->error_object_name, &errobj) < 0) {
171172
return NULL;
@@ -187,8 +188,7 @@ _ctypes_get_errobj(ctypes_state *st, int **pspace)
187188
PyMem_Free(space);
188189
return NULL;
189190
}
190-
if (-1 == PyDict_SetItem(dict, st->error_object_name,
191-
errobj)) {
191+
if (PyDict_SetItem(dict, st->error_object_name, errobj) < 0) {
192192
Py_DECREF(errobj);
193193
return NULL;
194194
}
@@ -1022,9 +1022,10 @@ static PyObject *GetResult(ctypes_state *st,
10221022
if (info->getfunc == _ctypes_get_fielddesc("O")->getfunc) {
10231023
Py_DECREF(retval);
10241024
}
1025-
} else
1025+
}
1026+
else {
10261027
retval = PyCData_FromBaseObj(st, restype, NULL, 0, result);
1027-
1028+
}
10281029
if (!checker || !retval)
10291030
return retval;
10301031

@@ -1464,8 +1465,9 @@ copy_com_pointer(PyObject *self, PyObject *args)
14641465
a.keep = b.keep = NULL;
14651466

14661467
ctypes_state *st = GLOBAL_STATE();
1467-
if (-1 == ConvParam(st, p1, 0, &a) || -1 == ConvParam(st, p2, 1, &b))
1468+
if (ConvParam(st, p1, 0, &a) < 0 || ConvParam(st, p2, 1, &b) < 0) {
14681469
goto done;
1470+
}
14691471
src = (IUnknown *)a.value.p;
14701472
pdst = (IUnknown **)b.value.p;
14711473

@@ -1988,7 +1990,7 @@ create_pointer_type(PyObject *module, PyObject *cls)
19881990
PyErr_SetString(PyExc_TypeError, "must be a ctypes type");
19891991
return NULL;
19901992
}
1991-
if (-1 == PyDict_SetItem(st->_ctypes_ptrtype_cache, key, result)) {
1993+
if (PyDict_SetItem(st->_ctypes_ptrtype_cache, key, result) < 0) {
19921994
Py_DECREF(result);
19931995
Py_DECREF(key);
19941996
return NULL;

0 commit comments

Comments
 (0)
0