Skip to content

Commit 2ebc68c

Browse files
Fix some compiler warnings.
1 parent 9065001 commit 2ebc68c

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

Modules/_xxsubinterpretersmodule.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,12 +1185,15 @@ channelid_richcompare(PyObject *self, PyObject *other, int op)
11851185
Py_RETURN_NOTIMPLEMENTED;
11861186
}
11871187

1188-
int64_t cid = ((channelid *)self)->id;
1189-
int64_t othercid;
1188+
channelid *cid = (channelid *)self;
1189+
int equal;
11901190
if (PyObject_TypeCheck(other, &ChannelIDtype)) {
1191-
othercid = ((channelid *)other)->id;
1192-
if (((channelid *)other)->end != ((channelid *)self)->end) {
1193-
Py_RETURN_FALSE;
1191+
channelid *othercid = (channelid *)other;
1192+
if (cid->end != othercid->end) {
1193+
equal = 0;
1194+
}
1195+
else {
1196+
equal = (cid->id == othercid->id);
11941197
}
11951198
}
11961199
else {
@@ -1199,15 +1202,23 @@ channelid_richcompare(PyObject *self, PyObject *other, int op)
11991202
PyErr_Clear();
12001203
Py_RETURN_NOTIMPLEMENTED;
12011204
}
1202-
othercid = PyLong_AsLongLong(other);
1205+
int64_t othercid = PyLong_AsLongLong(other);
1206+
// XXX decref other here?
12031207
if (othercid == -1 && PyErr_Occurred() != NULL) {
12041208
return NULL;
12051209
}
12061210
if (othercid < 0 || othercid > INT64_MAX) {
1207-
Py_RETURN_FALSE;
1211+
equal = 0;
1212+
}
1213+
else {
1214+
equal = (cid->id == othercid);
12081215
}
12091216
}
1210-
Py_RETURN_RICHCOMPARE(othercid != cid, 0, op);
1217+
1218+
if ((op == Py_EQ && equal) || (op == Py_NE && !equal)) {
1219+
Py_RETURN_TRUE;
1220+
}
1221+
Py_RETURN_FALSE;
12111222
}
12121223

12131224
struct _channelid_xid {
@@ -1477,7 +1488,7 @@ _run_script_in_interpreter(PyInterpreterState *interp, const char *codestr,
14771488
hold PyObject values. */
14781489
static struct globals {
14791490
_channels channels;
1480-
} _globals = {0};
1491+
} _globals = {{0}};
14811492

14821493
static int
14831494
_init_globals(void)

0 commit comments

Comments
 (0)