Skip to content

Commit 0b3ec19

Browse files
Use NULL rather than 0. (#778)
There was few cases of using literal 0 instead of NULL in the context of pointers. While this was a legitimate C code, using NULL rather than 0 makes the code clearer.
1 parent aefa7eb commit 0b3ec19

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

Modules/_csv.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,14 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
365365
Py_INCREF(dialect);
366366
/* Can we reuse this instance? */
367367
if (PyObject_TypeCheck(dialect, &Dialect_Type) &&
368-
delimiter == 0 &&
369-
doublequote == 0 &&
370-
escapechar == 0 &&
371-
lineterminator == 0 &&
372-
quotechar == 0 &&
373-
quoting == 0 &&
374-
skipinitialspace == 0 &&
375-
strict == 0)
368+
delimiter == NULL &&
369+
doublequote == NULL &&
370+
escapechar == NULL &&
371+
lineterminator == NULL &&
372+
quotechar == NULL &&
373+
quoting == NULL &&
374+
skipinitialspace == NULL &&
375+
strict == NULL)
376376
return dialect;
377377
}
378378

Modules/_ctypes/callproc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ _ctypes_get_errobj(int **pspace)
132132
PyObject *dict = PyThreadState_GetDict();
133133
PyObject *errobj;
134134
static PyObject *error_object_name;
135-
if (dict == 0) {
135+
if (dict == NULL) {
136136
PyErr_SetString(PyExc_RuntimeError,
137137
"cannot get thread state");
138138
return NULL;

Modules/_cursesmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2987,7 +2987,7 @@ PyCurses_tigetstr(PyObject *self, PyObject *args)
29872987
return NULL;
29882988

29892989
capname = tigetstr( capname );
2990-
if (capname == 0 || capname == (char*) -1) {
2990+
if (capname == NULL || capname == (char*) -1) {
29912991
Py_RETURN_NONE;
29922992
}
29932993
return PyBytes_FromString( capname );

Modules/_sqlite/connection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
643643

644644
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
645645

646-
if (*aggregate_instance == 0) {
646+
if (*aggregate_instance == NULL) {
647647
*aggregate_instance = _PyObject_CallNoArg(aggregate_class);
648648

649649
if (PyErr_Occurred()) {

Modules/_sqlite/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
434434
PyDict_SetItemString(dict, "OptimizedUnicode", (PyObject*)&PyUnicode_Type);
435435

436436
/* Set integer constants */
437-
for (i = 0; _int_constants[i].constant_name != 0; i++) {
437+
for (i = 0; _int_constants[i].constant_name != NULL; i++) {
438438
tmp_obj = PyLong_FromLong(_int_constants[i].constant_value);
439439
if (!tmp_obj) {
440440
goto error;

Modules/_tkinter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ Tkapp_CallArgs(PyObject *args, Tcl_Obj** objStore, int *pobjc)
13781378

13791379
else if (!(PyTuple_Check(args) || PyList_Check(args))) {
13801380
objv[0] = AsObj(args);
1381-
if (objv[0] == 0)
1381+
if (objv[0] == NULL)
13821382
goto finally;
13831383
objc = 1;
13841384
Tcl_IncrRefCount(objv[0]);

PC/bdist_wininst/install.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,7 @@ BOOL MyIsUserAnAdmin()
21792179
// to leave the library loaded)
21802180
if (0 == (shell32=LoadLibrary("shell32.dll")))
21812181
return FALSE;
2182-
if (0 == (pfnIsUserAnAdmin=(PFNIsUserAnAdmin)GetProcAddress(shell32, "IsUserAnAdmin")))
2182+
if (NULL == (pfnIsUserAnAdmin=(PFNIsUserAnAdmin)GetProcAddress(shell32, "IsUserAnAdmin")))
21832183
return FALSE;
21842184
return (*pfnIsUserAnAdmin)();
21852185
}

Parser/listnode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ listnode(FILE *fp, node *n)
2828
static void
2929
list1node(FILE *fp, node *n)
3030
{
31-
if (n == 0)
31+
if (n == NULL)
3232
return;
3333
if (ISNONTERMINAL(TYPE(n))) {
3434
int i;

0 commit comments

Comments
 (0)