Re: Remove PointerIsValid() - Mailing list pgsql-hackers

From Jacob Champion
Subject Re: Remove PointerIsValid()
Date
Msg-id CAOYmi+nd_cxU=rTaBeRu-E3P1WQUZeJmUJ1DVXXVkb5NSWgt3A@mail.gmail.com
Whole thread Raw
In response to Re: Remove PointerIsValid()  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Tue, Sep 16, 2025 at 10:21 PM Peter Eisentraut <peter@eisentraut.org> wrote:
>
> I think there is agreement that the PointerIsValid() macro is pretty
> useless.  This patch proposes to remove it.  There have been a few
> recent mini-discussions in other threads that appear to support this. [0][1]

Patch LGTM, and I like your chosen balance of the two replacements.

On Wed, Sep 17, 2025 at 8:55 AM Robert Haas <robertmhaas@gmail.com> wrote:
>
> 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
thatexplicitly 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.

(I find `if (some_pointer)` to be very readable, idiomatic C, so I
would vote against standardization.)

--Jacob



pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Parallel heap vacuum
Next
From: Robert Haas
Date:
Subject: Re: Parallel heap vacuum