mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
BUILD: debug: fix build issues in COUNT_IF() with -Wunused-value
Commit 7f64bb79fd
("BUG/MINOR: debug: COUNT_IF() should return true/false")
allowed the COUNT_IF() macro to return the evaluated value. This is handy
to place it in "if ()" conditions and count them at the same time. When
glitches are disabled, the condition is just returned as-is, but most call
places do not use the result, making some compilers complain. In addition,
while reviewing this, it was noticed that when DEBUG_STRICT=0, the macro
would still be replaced by a "do { } while (0)" statement, which not only
does not evaluate the expression, but also cannot return anything. Ditto
for COUNT_IF_HOT().
Let's make sure both are always properly evaluated now.
This commit is contained in:
parent
cb21db04c7
commit
d6dc8120c0
@ -245,7 +245,7 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt HA_SECTION_S
|
||||
|
||||
#else /* USE_OBSOLETE_LINKER not defined below */
|
||||
# define __DBG_COUNT(cond, file, line, type, ...) do { } while (0)
|
||||
# define _COUNT_IF(cond, file, line, ...) (cond)
|
||||
# define _COUNT_IF(cond, file, line, ...) DISGUISE(cond)
|
||||
# define _COUNT_GLITCH(file, line, ...) do { } while (0)
|
||||
#endif
|
||||
|
||||
@ -351,7 +351,7 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt HA_SECTION_S
|
||||
# define BUG_ON(cond, ...) do { (void)sizeof(cond); } while (0)
|
||||
# define WARN_ON(cond, ...) do { (void)sizeof(cond); } while (0)
|
||||
# define CHECK_IF(cond, ...) do { (void)sizeof(cond); } while (0)
|
||||
# define COUNT_IF(cond, ...) do { (void)sizeof(cond); } while (0)
|
||||
# define COUNT_IF(cond, ...) DISGUISE(cond)
|
||||
#endif
|
||||
|
||||
/* These macros are only for hot paths and remain disabled unless DEBUG_STRICT is 2 or above.
|
||||
@ -378,7 +378,7 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt HA_SECTION_S
|
||||
#else
|
||||
# define BUG_ON_HOT(cond, ...) do { (void)sizeof(cond) ; } while (0)
|
||||
# define CHECK_IF_HOT(cond, ...) do { (void)sizeof(cond) ; } while (0)
|
||||
# define COUNT_IF_HOT(cond, ...) do { (void)sizeof(cond) ; } while (0)
|
||||
# define COUNT_IF_HOT(cond, ...) DISGUISE(cond)
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user