diff options
| author | Peter Eisentraut <peter@eisentraut.org> | 2022-12-08 14:30:01 +0100 |
|---|---|---|
| committer | Peter Eisentraut <peter@eisentraut.org> | 2022-12-15 10:10:32 +0100 |
| commit | 75f49221c22286104f032827359783aa5f4e6646 (patch) | |
| tree | b4ac92eb6c557b4fd1ef6eda35ce9943564aba11 /src/backend/storage/page | |
| parent | 2613dec4ed67c4a963d987cbd29284e0634b65c9 (diff) | |
Static assertions cleanup
Because we added StaticAssertStmt() first before StaticAssertDecl(),
some uses as well as the instructions in c.h are now a bit backwards
from the "native" way static assertions are meant to be used in C.
This updates the guidance and moves some static assertions to better
places.
Specifically, since the addition of StaticAssertDecl(), we can put
static assertions at the file level. This moves a number of static
assertions out of function bodies, where they might have been stuck
out of necessity, to perhaps better places at the file level or in
header files.
Also, when the static assertion appears in a position where a
declaration is allowed, then using StaticAssertDecl() is more native
than StaticAssertStmt().
Reviewed-by: John Naylor <john.naylor@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/941a04e7-dd6f-c0e4-8cdf-a33b3338cbda%40enterprisedb.com
Diffstat (limited to 'src/backend/storage/page')
| -rw-r--r-- | src/backend/storage/page/itemptr.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/backend/storage/page/itemptr.c b/src/backend/storage/page/itemptr.c index 9011337aa81..5c98a5ec2b8 100644 --- a/src/backend/storage/page/itemptr.c +++ b/src/backend/storage/page/itemptr.c @@ -18,6 +18,12 @@ /* + * We really want ItemPointerData to be exactly 6 bytes. + */ +StaticAssertDecl(sizeof(ItemPointerData) == 3 * sizeof(uint16), + "ItemPointerData struct is improperly padded"); + +/* * ItemPointerEquals * Returns true if both item pointers point to the same item, * otherwise returns false. @@ -28,13 +34,6 @@ bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2) { - /* - * We really want ItemPointerData to be exactly 6 bytes. This is rather a - * random place to check, but there is no better place. - */ - StaticAssertStmt(sizeof(ItemPointerData) == 3 * sizeof(uint16), - "ItemPointerData struct is improperly padded"); - if (ItemPointerGetBlockNumber(pointer1) == ItemPointerGetBlockNumber(pointer2) && ItemPointerGetOffsetNumber(pointer1) == |
