typedef indentation in pg_shmem.h

Started by Ashutosh Bapat1 day ago6 messages
#1Ashutosh Bapat
ashutosh.bapat.oss@gmail.com
1 attachment(s)

Hi Heikki, Thomas,

The typedefs PGShmemType and HugePagesType are not indented properly.
That's because those entries are missing from typedefs list. Is that
intentional? Here's tiny patch fixing the indentation and typedefs
list.

--
Best Wishes,
Ashutosh Bapat

Attachments:

v20260112-0001-Indentation-of-PGShmemType-and-HugePagesTy.patchtext/x-patch; charset=US-ASCII; name=v20260112-0001-Indentation-of-PGShmemType-and-HugePagesTy.patchDownload
From 53c3ac6572345a0d581aec9d70c94e66ccfafc53 Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: Mon, 12 Jan 2026 14:34:01 +0530
Subject: [PATCH v20260112] Indentation of PGShmemType and HugePagesType
 typedefs

These typedefs are absent from typedefs.list, causing pgindent to misindent
them. Fix the indentation as well as typedefs.list.

Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
---
 src/include/storage/pg_shmem.h   | 4 ++--
 src/tools/pgindent/typedefs.list | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/include/storage/pg_shmem.h b/src/include/storage/pg_shmem.h
index 3aeada554b2..6f93e338006 100644
--- a/src/include/storage/pg_shmem.h
+++ b/src/include/storage/pg_shmem.h
@@ -54,7 +54,7 @@ typedef enum
 	HUGE_PAGES_ON,
 	HUGE_PAGES_TRY,				/* only for huge_pages */
 	HUGE_PAGES_UNKNOWN,			/* only for huge_pages_status */
-}			HugePagesType;
+} HugePagesType;
 
 /* Possible values for shared_memory_type */
 typedef enum
@@ -62,7 +62,7 @@ typedef enum
 	SHMEM_TYPE_WINDOWS,
 	SHMEM_TYPE_SYSV,
 	SHMEM_TYPE_MMAP,
-}			PGShmemType;
+} PGShmemType;
 
 #ifndef WIN32
 extern PGDLLIMPORT unsigned long UsedShmemSegID;
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 09e7f1d420e..659aa5b718d 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -1220,6 +1220,7 @@ HeapTupleHeaderData
 HeapTupleTableSlot
 HistControl
 HotStandbyState
+HugePagesType
 I32
 ICU_Convert_Func
 ID
@@ -1902,6 +1903,7 @@ PGRUsage
 PGSemaphore
 PGSemaphoreData
 PGShmemHeader
+PGShmemType
 PGTargetServerType
 PGTernaryBool
 PGTransactionStatusType

base-commit: e39ece0343fef7bf5a689d75bbafff9386e6e3da
-- 
2.34.1

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ashutosh Bapat (#1)
Re: typedef indentation in pg_shmem.h

Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> writes:

The typedefs PGShmemType and HugePagesType are not indented properly.
That's because those entries are missing from typedefs list. Is that
intentional?

The reason this happens is that the automatic process for collecting
typedefs in the buildfarm only picks up typedef names that are used
to declare objects (variables, struct fields, function parameters or
results).

AFAICS neither of these typedef names are referenced at all, anywhere.

Here's tiny patch fixing the indentation and typedefs
list.

I don't think this is helpful, because that change will just get
undone the next time we absorb the buildfarm's list. (And to be
clear, I consider the buildfarm's list to be the canonical one.)

I think the right way is to remove the unused typedefs, that is
along the lines of

-typedef enum
+enum HugePagesType
 {
...
-}			HugePagesType;
+};

We can put them back when/if there's a reason to use them.

regards, tom lane

#3Ashutosh Bapat
ashutosh.bapat.oss@gmail.com
In reply to: Tom Lane (#2)
1 attachment(s)
Re: typedef indentation in pg_shmem.h

Hi Tom,

On Mon, Jan 12, 2026 at 8:32 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> writes:

The typedefs PGShmemType and HugePagesType are not indented properly.
That's because those entries are missing from typedefs list. Is that
intentional?

The reason this happens is that the automatic process for collecting
typedefs in the buildfarm only picks up typedef names that are used
to declare objects (variables, struct fields, function parameters or
results).

AFAICS neither of these typedef names are referenced at all, anywhere.

Here's tiny patch fixing the indentation and typedefs
list.

I don't think this is helpful, because that change will just get
undone the next time we absorb the buildfarm's list. (And to be
clear, I consider the buildfarm's list to be the canonical one.)

I think the right way is to remove the unused typedefs, that is
along the lines of

-typedef enum
+enum HugePagesType
{
...
-}                      HugePagesType;
+};

We can put them back when/if there's a reason to use them.

Thanks for your corrections. Your idea works, the changes survive
pgindent run. PFA patch.

--
Best Wishes,
Ashutosh Bapat

Attachments:

v20260112-0001-Fix-PGShmemType-and-HugePagesType-typedefs.patchtext/x-patch; charset=US-ASCII; name=v20260112-0001-Fix-PGShmemType-and-HugePagesType-typedefs.patchDownload
From 8558a47360a31f9d9b10133702b40b1398bdce99 Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: Mon, 12 Jan 2026 14:34:01 +0530
Subject: [PATCH v20260112] Fix PGShmemType and HugePagesType typedefs

The automatic process for collecting typedefs in the buildfarm only picks up
typedef names that are used to declare objects (variables, struct fields,
function parameters or results). The typedef names mentioned in the subject are
not referenced at all, anywhere. Hence they are not picked up by the buildfarm
process causing their declarations to be wrongly indented. This commit changes
them to plain enums thus avoiding the wrong indentation.

Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Fix suggested by: Tom Lane <tgl@sss.pgh.pa.us>
---
 src/include/storage/pg_shmem.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/include/storage/pg_shmem.h b/src/include/storage/pg_shmem.h
index 3aeada554b2..b1803278542 100644
--- a/src/include/storage/pg_shmem.h
+++ b/src/include/storage/pg_shmem.h
@@ -48,21 +48,21 @@ extern PGDLLIMPORT int huge_page_size;
 extern PGDLLIMPORT int huge_pages_status;
 
 /* Possible values for huge_pages and huge_pages_status */
-typedef enum
+enum HugePagesType
 {
 	HUGE_PAGES_OFF,
 	HUGE_PAGES_ON,
 	HUGE_PAGES_TRY,				/* only for huge_pages */
 	HUGE_PAGES_UNKNOWN,			/* only for huge_pages_status */
-}			HugePagesType;
+};
 
 /* Possible values for shared_memory_type */
-typedef enum
+enum PGShmemType
 {
 	SHMEM_TYPE_WINDOWS,
 	SHMEM_TYPE_SYSV,
 	SHMEM_TYPE_MMAP,
-}			PGShmemType;
+};
 
 #ifndef WIN32
 extern PGDLLIMPORT unsigned long UsedShmemSegID;

base-commit: 707f905399b4e47c295fe247f76fbbe53c737984
-- 
2.34.1

#4zengman
zengman@halodbtech.com
In reply to: Ashutosh Bapat (#3)
Re: typedef indentation in pg_shmem.h

The typedefs PGShmemType and HugePagesType are not indented properly.
That's because those entries are missing from typedefs list. Is that
intentional? Here's tiny patch fixing the indentation and typedefs
list.

Hi all,

I just came across this email and wanted to chime in: it appears that a number of types in the kernel have in fact been omitted from the typedefs.list, and it’s likely they were overlooked. For example:
```
BTParallelScanDescData
AfterTriggerEventDataNoOids
AfterTriggerEventDataOneCtid
AfterTriggerEventDataZeroCtids
PartitionDispatchData
MergeJoinClauseData
BufferAccessStrategyData
lwlock_stats_key
lwlock_stats
SerialControlData
AllocBlockData
```
I’m wondering if it’s worth addressing these.

--
Regards,
Man Zeng
www.openhalo.org

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: zengman (#4)
Re: typedef indentation in pg_shmem.h

"=?gb18030?B?emVuZ21hbg==?=" <zengman@halodbtech.com> writes:

I just came across this email and wanted to chime in: it appears that a number of types in the kernel have in fact been omitted from the typedefs.list, and it¡¯s likely they were overlooked. For example:
BTParallelScanDescData
AfterTriggerEventDataNoOids
AfterTriggerEventDataOneCtid
AfterTriggerEventDataZeroCtids
PartitionDispatchData
MergeJoinClauseData
BufferAccessStrategyData
lwlock_stats_key
lwlock_stats
SerialControlData
AllocBlockData

Did you read my reply?

regards, tom lane

#6zengman
zengman@halodbtech.com
In reply to: Tom Lane (#5)
Re: typedef indentation in pg_shmem.h

Did you read my reply?

Hi Tom,

Oh wow, I’ve re-read your previous message carefully, and I realize I overlooked or misunderstood it earlier.
Sorry for the interruption.

--
Regards,
Man Zeng
www.openhalo.org