Use NULL rather than 0. (#778) · pythoncapi/cpython@0b3ec19 · GitHub
Skip to content

Commit 0b3ec19

Browse files
Use NULL rather than 0. (python#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

8 files changed

Lines changed: 15 additions & 15 deletions

File tree

Modules/_csv.c

Lines changed: 8 additions & 8 deletions

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

0 commit comments

Comments
 (0)