From bf183f168c447355ba82151f1c7305368a95c834 Mon Sep 17 00:00:00 2001 From: John Naylor Date: Tue, 9 Apr 2024 16:16:01 +0700 Subject: [PATCH] Get rid of anonymous struct This is a C11 feature, and we require C99. While at it, go the further step and get rid of the surrounding union (with uintptr_t) entirely, as there is currently no use case for this file to access the header of BlocktableEntry as a uintptr_t, and there are no additional alignment requirements. The least invasive way seems to be to transfer the old union name to this struct. Reported by Pavel Borisov and Andres Freund, per buildfarm member mylodon Reviewed by Pavel Borisov Discussion: https://postgr.es/m/CALT9ZEH11NYV8AOzKb1bWhCf6J0H=H31f0MgT9xX+HdqvcA1rw@mail.gmail.com --- src/backend/access/common/tidstore.c | 41 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/backend/access/common/tidstore.c b/src/backend/access/common/tidstore.c index cddbaf013b..fb3949d69f 100644 --- a/src/backend/access/common/tidstore.c +++ b/src/backend/access/common/tidstore.c @@ -43,37 +43,36 @@ */ typedef struct BlocktableEntry { - union + struct { - struct - { #ifndef WORDS_BIGENDIAN - /* - * We need to position this member so that the backing radix tree - * can use the lowest bit for a pointer tag. In particular, it - * must be placed within 'header' so that it corresponds to the - * lowest byte in 'ptr'. We position 'nwords' along with it to - * avoid struct padding. - */ - uint8 flags; + /* + * We need to position this member to reserve space for the backing + * radix tree to tag the lowest bit when struct 'header' is stored + * inside a pointer or DSA pointer. + */ + uint8 flags; - int8 nwords; + int8 nwords; #endif - /* - * We can store a small number of offsets here to avoid wasting - * space with a sparse bitmap. - */ - OffsetNumber full_offsets[NUM_FULL_OFFSETS]; + /* + * We can store a small number of offsets here to avoid wasting space + * with a sparse bitmap. + */ + OffsetNumber full_offsets[NUM_FULL_OFFSETS]; #ifdef WORDS_BIGENDIAN - int8 nwords; - uint8 flags; + int8 nwords; + uint8 flags; #endif - }; - uintptr_t ptr; } header; + /* + * We don't expect any padding space here, but to be cautious, code + * creating new entries should zero out space up to 'words'. + */ + bitmapword words[FLEXIBLE_ARRAY_MEMBER]; } BlocktableEntry;