Skip to content

Commit bf183f1

Browse files
committed
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
1 parent baa82b7 commit bf183f1

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/backend/access/common/tidstore.c

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,36 @@
4343
*/
4444
typedef struct BlocktableEntry
4545
{
46-
union
46+
struct
4747
{
48-
struct
49-
{
5048
#ifndef WORDS_BIGENDIAN
51-
/*
52-
* We need to position this member so that the backing radix tree
53-
* can use the lowest bit for a pointer tag. In particular, it
54-
* must be placed within 'header' so that it corresponds to the
55-
* lowest byte in 'ptr'. We position 'nwords' along with it to
56-
* avoid struct padding.
57-
*/
58-
uint8 flags;
59-
60-
int8 nwords;
49+
/*
50+
* We need to position this member to reserve space for the backing
51+
* radix tree to tag the lowest bit when struct 'header' is stored
52+
* inside a pointer or DSA pointer.
53+
*/
54+
uint8 flags;
55+
56+
int8 nwords;
6157
#endif
6258

63-
/*
64-
* We can store a small number of offsets here to avoid wasting
65-
* space with a sparse bitmap.
66-
*/
67-
OffsetNumber full_offsets[NUM_FULL_OFFSETS];
59+
/*
60+
* We can store a small number of offsets here to avoid wasting space
61+
* with a sparse bitmap.
62+
*/
63+
OffsetNumber full_offsets[NUM_FULL_OFFSETS];
6864

6965
#ifdef WORDS_BIGENDIAN
70-
int8 nwords;
71-
uint8 flags;
66+
int8 nwords;
67+
uint8 flags;
7268
#endif
73-
};
74-
uintptr_t ptr;
7569
} header;
7670

71+
/*
72+
* We don't expect any padding space here, but to be cautious, code
73+
* creating new entries should zero out space up to 'words'.
74+
*/
75+
7776
bitmapword words[FLEXIBLE_ARRAY_MEMBER];
7877
} BlocktableEntry;
7978

0 commit comments

Comments
 (0)