Content-Length: 341121 | pFad | http://github.com/postgrespro/postgres_cluster/commit/51940f97607b7cb4d03bdd99e43abb1a1c6a0c47

12 Cast to void in StaticAssertExpr, not its callers. · postgrespro/postgres_cluster@51940f9 · GitHub
Skip to content

Commit 51940f9

Browse files
committed
Cast to void in StaticAssertExpr, not its callers.
Seems a bit silly that many (in fact all, as of today) uses of StaticAssertExpr would need to cast it to void to avoid warnings from pickier compilers. Let's just do the cast right in the macro, instead. In passing, change StaticAssertExpr to StaticAssertStmt in one place where that seems more apropos. Discussion: https://postgr.es/m/16161.1518715186@sss.pgh.pa.us
1 parent 03c5a00 commit 51940f9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/backend/storage/lmgr/lwlock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,10 @@ LWLockShmemSize(void)
380380
void
381381
CreateLWLocks(void)
382382
{
383-
StaticAssertExpr(LW_VAL_EXCLUSIVE > (uint32) MAX_BACKENDS,
383+
StaticAssertStmt(LW_VAL_EXCLUSIVE > (uint32) MAX_BACKENDS,
384384
"MAX_BACKENDS too big for lwlock.c");
385385

386-
StaticAssertExpr(sizeof(LWLock) <= LWLOCK_MINIMAL_SIZE &&
386+
StaticAssertStmt(sizeof(LWLock) <= LWLOCK_MINIMAL_SIZE &&
387387
sizeof(LWLock) <= LWLOCK_PADDED_SIZE,
388388
"Miscalculated LWLock padding");
389389

src/include/c.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ extern void ExceptionalCondition(const char *conditionName,
779779
#define StaticAssertStmt(condition, errmessage) \
780780
do { _Static_assert(condition, errmessage); } while(0)
781781
#define StaticAssertExpr(condition, errmessage) \
782-
({ StaticAssertStmt(condition, errmessage); true; })
782+
((void) ({ StaticAssertStmt(condition, errmessage); true; }))
783783
#else /* !HAVE__STATIC_ASSERT */
784784
#define StaticAssertStmt(condition, errmessage) \
785785
((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; }))
@@ -796,7 +796,7 @@ extern void ExceptionalCondition(const char *conditionName,
796796
#define StaticAssertStmt(condition, errmessage) \
797797
do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0)
798798
#define StaticAssertExpr(condition, errmessage) \
799-
({ StaticAssertStmt(condition, errmessage); })
799+
((void) ({ StaticAssertStmt(condition, errmessage); }))
800800
#endif
801801
#endif /* C++ */
802802

@@ -817,14 +817,14 @@ extern void ExceptionalCondition(const char *conditionName,
817817
StaticAssertStmt(__builtin_types_compatible_p(__typeof__(varname), typename), \
818818
CppAsString(varname) " does not have type " CppAsString(typename))
819819
#define AssertVariableIsOfTypeMacro(varname, typename) \
820-
((void) StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
820+
(StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
821821
CppAsString(varname) " does not have type " CppAsString(typename)))
822822
#else /* !HAVE__BUILTIN_TYPES_COMPATIBLE_P */
823823
#define AssertVariableIsOfType(varname, typename) \
824824
StaticAssertStmt(sizeof(varname) == sizeof(typename), \
825825
CppAsString(varname) " does not have type " CppAsString(typename))
826826
#define AssertVariableIsOfTypeMacro(varname, typename) \
827-
((void) StaticAssertExpr(sizeof(varname) == sizeof(typename), \
827+
(StaticAssertExpr(sizeof(varname) == sizeof(typename), \
828828
CppAsString(varname) " does not have type " CppAsString(typename)))
829829
#endif /* HAVE__BUILTIN_TYPES_COMPATIBLE_P */
830830

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres_cluster/commit/51940f97607b7cb4d03bdd99e43abb1a1c6a0c47

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy