Re: Remove PointerIsValid()

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: Chao Li <li.evan.chao@gmail.com>
Cc: Peter Eisentraut <peter@eisentraut.org>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-09-17T15:54:46Z
Lists: pgsql-hackers
On Wed, Sep 17, 2025 at 4:12 AM Chao Li <li.evan.chao@gmail.com> wrote:
> Given the context of replacing PointerIsValid(x), I think if (foo != NULL) is slightly better than if (x), because that explicitly shows the intent of checking pointers, while if (x) works for both pointers and integers.

I agree that we should prefer foo != NULL, but if the surrounding code
in a particular location just tests if (foo), then it may be better in
that case to go that route.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



Commits

  1. Remove PointerIsValid()