Re: Remove useless pointer advance in StatsShmemInit() - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Re: Remove useless pointer advance in StatsShmemInit()
Date
Msg-id aS6X/ANu70ujALPu@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
In response to Re: Remove useless pointer advance in StatsShmemInit()  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Remove useless pointer advance in StatsShmemInit()
List pgsql-hackers
Hi,

On Tue, Aug 19, 2025 at 10:00:37AM +0900, Michael Paquier wrote:
> On Mon, Aug 18, 2025 at 09:31:14AM +0000, Bertrand Drouvot wrote:
> > Yeah, that's probably just a matter of taste, but I also prefer keeping the
> > pointer over just doing:
> > 
> > ctl->raw_dsa_area = (char *) ctl + MAXALIGN(sizeof(PgStat_ShmemControl));
> 
> Done as you have suggested.

Here are a few more that have been found with [1]. I did review all of them
carefully and they look legitimate to remove.

That said, I chose not to remove some and added comments instead for:

- the last ones in ParseCommitRecord(), ParseAbortRecord() and ParsePrepareRecord()
- some in ReorderBufferSerializeChange() 
- the one in SnapBuildSerialize()

The reason is that, while they are currently useless, they would need to be
added back if we add more branches/cases. So I preferred to stay on the safe side
of thing.

Remarks:

- we could also add a comment instead of removing the one in DecodeXLogRecord(),
but we're in the "and finally, the main data" part so I don't think there are
risks to have to add it back.

- for the ones in ReorderBufferRestoreChange(): While data is a parameter,
modifying the pointer itself (not *data) only affects the local copy, so these
increments are dead code.

- for the ones in pgaio_uring_shmem_init(), I'm not sure if we should keep them
for "documentation" purpose or remove them. The current patch removes them,
but feedback is welcome.


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

Regards,

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

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Remove unused function parameters, part 2: replication
Next
From: Peter Eisentraut
Date:
Subject: Re: Consistently use the XLogRecPtrIsInvalid() macro