]> granicus.if.org Git - python/commitdiff
Use NULL rather than 0. (#778)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 23 Mar 2017 15:53:47 +0000 (17:53 +0200)
committerGitHub <noreply@github.com>
Thu, 23 Mar 2017 15:53:47 +0000 (17:53 +0200)
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.

Modules/_csv.c
Modules/_ctypes/callproc.c
Modules/_cursesmodule.c
Modules/_sqlite/connection.c
Modules/_sqlite/module.c
Modules/_tkinter.c
PC/bdist_wininst/install.c
Parser/listnode.c

index fb5530ab572259adbbc6c1944d20a924bb230346..5314ef6edc438285a732c5a52326d328ccc7edd7 100644 (file)
@@ -365,14 +365,14 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
             Py_INCREF(dialect);
         /* Can we reuse this instance? */
         if (PyObject_TypeCheck(dialect, &Dialect_Type) &&
-            delimiter == 0 &&
-            doublequote == 0 &&
-            escapechar == 0 &&
-            lineterminator == 0 &&
-            quotechar == 0 &&
-            quoting == 0 &&
-            skipinitialspace == 0 &&
-            strict == 0)
+            delimiter == NULL &&
+            doublequote == NULL &&
+            escapechar == NULL &&
+            lineterminator == NULL &&
+            quotechar == NULL &&
+            quoting == NULL &&
+            skipinitialspace == NULL &&
+            strict == NULL)
             return dialect;
     }
 
index 9b368caf65b58c067494b13697b1349719fa9e38..0b6faf96c68f6ac17e75f6aed25850f85f7b69f4 100644 (file)
@@ -132,7 +132,7 @@ _ctypes_get_errobj(int **pspace)
     PyObject *dict = PyThreadState_GetDict();
     PyObject *errobj;
     static PyObject *error_object_name;
-    if (dict == 0) {
+    if (dict == NULL) {
         PyErr_SetString(PyExc_RuntimeError,
                         "cannot get thread state");
         return NULL;
index 4d714cecdfb9545c2ddaf440b0f8ba84dd88867c..8f0a12bbb094d1777399da0247dcfd196d18771c 100644 (file)
@@ -2987,7 +2987,7 @@ PyCurses_tigetstr(PyObject *self, PyObject *args)
         return NULL;
 
     capname = tigetstr( capname );
-    if (capname == 0 || capname == (char*) -1) {
+    if (capname == NULL || capname == (char*) -1) {
         Py_RETURN_NONE;
     }
     return PyBytes_FromString( capname );
index 72156b91a4db83750d030c0ee0f01a6f62691aad..fab77ef20bb307181869aab578f0a046ca9181d3 100644 (file)
@@ -643,7 +643,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
 
     aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
 
-    if (*aggregate_instance == 0) {
+    if (*aggregate_instance == NULL) {
         *aggregate_instance = _PyObject_CallNoArg(aggregate_class);
 
         if (PyErr_Occurred()) {
index 72c3a7f34fca0e68b06d27b48164db23a345fd89..59406e1d77f4ad592385d2008f9455ef1cb51e4b 100644 (file)
@@ -434,7 +434,7 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
     PyDict_SetItemString(dict, "OptimizedUnicode", (PyObject*)&PyUnicode_Type);
 
     /* Set integer constants */
-    for (i = 0; _int_constants[i].constant_name != 0; i++) {
+    for (i = 0; _int_constants[i].constant_name != NULL; i++) {
         tmp_obj = PyLong_FromLong(_int_constants[i].constant_value);
         if (!tmp_obj) {
             goto error;
index ff5167453121c1f36a2f2d94399e5c9ad14a30d7..7ed2b0254bd7fd9be12eeecda17f282eaa580bde 100644 (file)
@@ -1378,7 +1378,7 @@ Tkapp_CallArgs(PyObject *args, Tcl_Obj** objStore, int *pobjc)
 
     else if (!(PyTuple_Check(args) || PyList_Check(args))) {
         objv[0] = AsObj(args);
-        if (objv[0] == 0)
+        if (objv[0] == NULL)
             goto finally;
         objc = 1;
         Tcl_IncrRefCount(objv[0]);
index 17cc30d25cf8f6931e7807e2aace1671b37b8256..4f9ef6c2cc4c775077bea2da73f41358adca19d5 100644 (file)
@@ -2179,7 +2179,7 @@ BOOL MyIsUserAnAdmin()
     // to leave the library loaded)
     if (0 == (shell32=LoadLibrary("shell32.dll")))
         return FALSE;
-    if (0 == (pfnIsUserAnAdmin=(PFNIsUserAnAdmin)GetProcAddress(shell32, "IsUserAnAdmin")))
+    if (NULL == (pfnIsUserAnAdmin=(PFNIsUserAnAdmin)GetProcAddress(shell32, "IsUserAnAdmin")))
         return FALSE;
     return (*pfnIsUserAnAdmin)();
 }
index b5f8ad23a92f89d1c2028ee6d786b991d0f4d672..71300ae908ae155753da4b088633a296d390fa60 100644 (file)
@@ -28,7 +28,7 @@ listnode(FILE *fp, node *n)
 static void
 list1node(FILE *fp, node *n)
 {
-    if (n == 0)
+    if (n == NULL)
         return;
     if (ISNONTERMINAL(TYPE(n))) {
         int i;