Re: Consistently use the XLogRecPtrIsInvalid() macro

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Michael Paquier <michael(at)paquier(dot)xyz>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Quan Zongliang <quanzongliang(at)yeah(dot)net>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Consistently use the XLogRecPtrIsInvalid() macro
Date: 2025-12-01 07:14:42
Message-ID: aS1AYnZmuRZ8g+5G@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Nov 18, 2025 at 04:54:32PM +0100, Peter Eisentraut wrote:
> I mean, some people like writing if (!foo) and some like writing if
> (foo == NULL), but we're not going to legislate one
> over the other.

Agree. Out of curiosity, I searched for pointers and literal zero comparisons
or assignments (with [1]) and found 6 of them.

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

PFA a patch to fix those 6.

[1]: https://github.com/bdrouvot/coccinelle_on_pg/blob/main/misc/pointers_and_literal_zero.cocci

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v1-0001-Replace-pointer-comparisons-and-assignments-to-li.patch text/x-diff 3.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message cca5507 2025-12-01 07:20:16 Re: [Patch] Build the heap more efficient in tuplesort.c
Previous Message Peter Eisentraut 2025-12-01 07:03:49 Re: alignas (C11)