Remove unused struct fields

Started by Bertrand Drouvot12 months ago3 messageshackers
Jump to latest
#1Bertrand Drouvot
bertranddrouvot.pg@gmail.com

Hi hackers,

Here are a few fields that are not used.

1) username in scram_state:

Added and used in 818fd4a67d61.
Usage removed in f3049a603a7.

2) mask in PgAioWorkerSubmissionQueue:

Added in and not used since 247ce06b883d.

3) write_page in SharedTuplestoreAccessor:

Added in and not used since ab9e0e718acb.

Those have been found with a coccinelle script [1]https://github.com/bdrouvot/coccinelle_on_pg/blob/main/misc/unused_struct_fields.cocci.

Note that it generates a lot of false positives and requires careful manual
review. I'll try to improve it if time permits.

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

Regards,

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

Attachments:

v1-0001-Remove-unused-struct-fields.patchtext/x-diff; charset=us-asciiDownload+2-10
#2Nathan Bossart
nathandbossart@gmail.com
In reply to: Bertrand Drouvot (#1)
Re: Remove unused struct fields

On Wed, Nov 26, 2025 at 02:54:48PM +0000, Bertrand Drouvot wrote:

Here are a few fields that are not used.

-	const char *username;		/* username from startup packet */
+	scram_state_enum state;		/* username from startup packet */
-	BlockNumber write_page;		/* The next page to write to. */
+	BufFile    *write_file;		/* The current file to write to. */		/* The next page to write to. */

Something weird happened with the comments for these two. Otherwise, this
seems reasonable to me.

--
nathan

#3Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#2)
Re: Remove unused struct fields

Committed.

--
nathan