Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit51940f9

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

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
#defineStaticAssertStmt(condition,errmessage) \
780780
do { _Static_assert(condition, errmessage); } while(0)
781781
#defineStaticAssertExpr(condition,errmessage) \
782-
({ StaticAssertStmt(condition, errmessage); true; })
782+
((void) ({ StaticAssertStmt(condition, errmessage); true; }))
783783
#else/* !HAVE__STATIC_ASSERT */
784784
#defineStaticAssertStmt(condition,errmessage) \
785785
((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; }))
@@ -796,7 +796,7 @@ extern void ExceptionalCondition(const char *conditionName,
796796
#defineStaticAssertStmt(condition,errmessage) \
797797
do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0)
798798
#defineStaticAssertExpr(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
#defineAssertVariableIsOfTypeMacro(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
#defineAssertVariableIsOfType(varname,typename) \
824824
StaticAssertStmt(sizeof(varname) == sizeof(typename), \
825825
CppAsString(varname) " does not have type " CppAsString(typename))
826826
#defineAssertVariableIsOfTypeMacro(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)

[8]ページ先頭

©2009-2025 Movatter.jp