Replace pointer comparisons and assignments to literal zero with NULL

While 0 is technically correct, NULL is the semantically appropriate
choice for pointers.

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/aS1AYnZmuRZ8g%2B5G%40ip-10-97-1-34.eu-west-3.compute.internal
This commit is contained in:
Peter Eisentraut 2025-12-02 08:39:24 +01:00
parent 376c649634
commit ec782f56b0
5 changed files with 6 additions and 6 deletions

View File

@ -204,7 +204,7 @@ copyObjectImpl(const void *from)
default: default:
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from)); elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
retval = 0; /* keep compiler quiet */ retval = NULL; /* keep compiler quiet */
break; break;
} }

View File

@ -3391,7 +3391,7 @@ LaunchMissingBackgroundProcesses(void)
Shutdown <= SmartShutdown) Shutdown <= SmartShutdown)
{ {
WalReceiverPMChild = StartChildProcess(B_WAL_RECEIVER); WalReceiverPMChild = StartChildProcess(B_WAL_RECEIVER);
if (WalReceiverPMChild != 0) if (WalReceiverPMChild != NULL)
WalReceiverRequested = false; WalReceiverRequested = false;
/* else leave the flag set, so we'll try again later */ /* else leave the flag set, so we'll try again later */
} }

View File

@ -1222,10 +1222,10 @@ pg_newlocale_from_collation(Oid collid)
* Make sure cache entry is marked invalid, in case we fail before * Make sure cache entry is marked invalid, in case we fail before
* setting things. * 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); cache_entry->locale = create_pg_locale(collid, CollationCacheContext);
} }

View File

@ -5161,7 +5161,7 @@ interval_trunc(PG_FUNCTION_ARGS)
errmsg("unit \"%s\" not supported for type %s", errmsg("unit \"%s\" not supported for type %s",
lowunits, format_type_be(INTERVALOID)), lowunits, format_type_be(INTERVALOID)),
(val == DTK_WEEK) ? errdetail("Months usually have fractional weeks.") : 0)); (val == DTK_WEEK) ? errdetail("Months usually have fractional weeks.") : 0));
result = 0; result = NULL;
} }
} }

View File

@ -509,7 +509,7 @@ ecpg_freeStmtCacheEntry(int lineno, int compat,
if (entry->ecpgQuery) if (entry->ecpgQuery)
{ {
ecpg_free(entry->ecpgQuery); ecpg_free(entry->ecpgQuery);
entry->ecpgQuery = 0; entry->ecpgQuery = NULL;
} }
return entNo; return entNo;