Replace pointer comparisons and assignments to literal zero with NULL
authorPeter Eisentraut <[email protected]>
Tue, 2 Dec 2025 07:39:24 +0000 (08:39 +0100)
committerPeter Eisentraut <[email protected]>
Tue, 2 Dec 2025 07:39:24 +0000 (08:39 +0100)
While 0 is technically correct, NULL is the semantically appropriate
choice for pointers.

Author: Bertrand Drouvot <[email protected]>
Discussion: https://www.postgresql.org/message-id/aS1AYnZmuRZ8g%2B5G%40ip-10-97-1-34.eu-west-3.compute.internal

src/backend/nodes/copyfuncs.c
src/backend/postmaster/postmaster.c
src/backend/utils/adt/pg_locale.c
src/backend/utils/adt/timestamp.c
src/interfaces/ecpg/ecpglib/prepare.c

index 475693b08bc5abd4024ed8cc62b1a8432498e478..efd02eb01c405f77c5d27a88a043f6cc3110c29f 100644 (file)
@@ -204,7 +204,7 @@ copyObjectImpl(const void *from)
 
                default:
                        elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
-                       retval = 0;                     /* keep compiler quiet */
+                       retval = NULL;          /* keep compiler quiet */
                        break;
        }
 
index 7c064cf9fbb288180380521dee24f5c03db439c4..a956db4ad27b27fcde50b40c1af7c5d91dec0a21 100644 (file)
@@ -3391,7 +3391,7 @@ LaunchMissingBackgroundProcesses(void)
                        Shutdown <= SmartShutdown)
                {
                        WalReceiverPMChild = StartChildProcess(B_WAL_RECEIVER);
-                       if (WalReceiverPMChild != 0)
+                       if (WalReceiverPMChild != NULL)
                                WalReceiverRequested = false;
                        /* else leave the flag set, so we'll try again later */
                }
index b02e7fa4f18ab4660dbd604339ea394cd81e145a..b26257c0a8df4e3a680a0090e8b46462095229a3 100644 (file)
@@ -1222,10 +1222,10 @@ pg_newlocale_from_collation(Oid collid)
                 * Make sure cache entry is marked invalid, in case we fail before
                 * setting things.
                 */
-               cache_entry->locale = 0;
+               cache_entry->locale = NULL;
        }
 
-       if (cache_entry->locale == 0)
+       if (cache_entry->locale == NULL)
        {
                cache_entry->locale = create_pg_locale(collid, CollationCacheContext);
        }
index af48527d436f9c5d81d492e85174e31a7468ee63..2dc90a2b8a9171ab36cdf076e345a6bfffceae2e 100644 (file)
@@ -5161,7 +5161,7 @@ interval_trunc(PG_FUNCTION_ARGS)
                                                         errmsg("unit \"%s\" not supported for type %s",
                                                                        lowunits, format_type_be(INTERVALOID)),
                                                         (val == DTK_WEEK) ? errdetail("Months usually have fractional weeks.") : 0));
-                                       result = 0;
+                                       result = NULL;
                        }
                }
 
index 4b1ae83950679b4f5b27d01ac9cfbf9163d7f9fc..a3f51993d70bace770a6116716b76cf01ff0745f 100644 (file)
@@ -509,7 +509,7 @@ ecpg_freeStmtCacheEntry(int lineno, int compat,
        if (entry->ecpgQuery)
        {
                ecpg_free(entry->ecpgQuery);
-               entry->ecpgQuery = 0;
+               entry->ecpgQuery = NULL;
        }
 
        return entNo;