Skip to content

Commit 8134fe4

Browse files
committed
Remove some pointless code in block.h.
There's no visible point in casting the result of a comparison to bool, because it already is that, at least on C99 compilers. I see no point in these assertions that a pointer we're about to dereference isn't null, either. If it is, the resulting SIGSEGV will notify us of the problem just fine. Noted while reviewing Zhihong Yu's patch. This is basically cosmetic, so no need for back-patch. Discussion: https://postgr.es/m/CALNJ-vT9r0DSsAOw9OXVJFxLENoVS_68kJ5x0p44atoYH+H4dg@mail.gmail.com
1 parent 0fbdfaf commit 8134fe4

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/include/storage/block.h

+3-9
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,21 @@ typedef BlockIdData *BlockId; /* block identifier */
6868
* True iff blockNumber is valid.
6969
*/
7070
#define BlockNumberIsValid(blockNumber) \
71-
((bool) ((BlockNumber) (blockNumber) != InvalidBlockNumber))
71+
((BlockNumber) (blockNumber) != InvalidBlockNumber)
7272

7373
/*
7474
* BlockIdIsValid
7575
* True iff the block identifier is valid.
7676
*/
7777
#define BlockIdIsValid(blockId) \
78-
((bool) PointerIsValid(blockId))
78+
PointerIsValid(blockId)
7979

8080
/*
8181
* BlockIdSet
8282
* Sets a block identifier to the specified value.
8383
*/
8484
#define BlockIdSet(blockId, blockNumber) \
8585
( \
86-
AssertMacro(PointerIsValid(blockId)), \
8786
(blockId)->bi_hi = (blockNumber) >> 16, \
8887
(blockId)->bi_lo = (blockNumber) & 0xffff \
8988
)
@@ -94,8 +93,6 @@ typedef BlockIdData *BlockId; /* block identifier */
9493
*/
9594
#define BlockIdCopy(toBlockId, fromBlockId) \
9695
( \
97-
AssertMacro(PointerIsValid(toBlockId)), \
98-
AssertMacro(PointerIsValid(fromBlockId)), \
9996
(toBlockId)->bi_hi = (fromBlockId)->bi_hi, \
10097
(toBlockId)->bi_lo = (fromBlockId)->bi_lo \
10198
)
@@ -113,9 +110,6 @@ typedef BlockIdData *BlockId; /* block identifier */
113110
* Retrieve the block number from a block identifier.
114111
*/
115112
#define BlockIdGetBlockNumber(blockId) \
116-
( \
117-
AssertMacro(BlockIdIsValid(blockId)), \
118-
((((BlockNumber) (blockId)->bi_hi) << 16) | ((BlockNumber) (blockId)->bi_lo)) \
119-
)
113+
((((BlockNumber) (blockId)->bi_hi) << 16) | ((BlockNumber) (blockId)->bi_lo))
120114

121115
#endif /* BLOCK_H */

0 commit comments

Comments
 (0)