BUG/MINOR: debug: COUNT_IF() should return true/false

The COUNT_IF() macro was initially meant to return true/false to be used
in if() conditions but had an extra do { } while(0) that prevents it from
doing so. Let's get rid of the do { } while(0) before the code generalizes
to too many places. There's no impact on existing code, but may have to be
backported if future fixes rely on it.
This commit is contained in:
Willy Tarreau 2024-11-27 14:24:16 +01:00
parent fc0bb6224c
commit 7f64bb79fd

View File

@ -225,11 +225,11 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt HA_SECTION_S
/* Core of the COUNT_IF() macro, checks the condition and counts one hit if
* true.
*/
#define _COUNT_IF(cond, file, line, ...) do { \
(void)(unlikely(cond) ? ({ \
#define _COUNT_IF(cond, file, line, ...) \
(unlikely(cond) ? ({ \
__DBG_COUNT(cond, file, line, DBG_COUNT_IF, __VA_ARGS__); \
1; /* let's return the true condition */ \
}) : 0); } while (0)
}) : 0)
/* DEBUG_GLITCHES enables counting the number of glitches per line of code. The
* condition is empty (nothing to write there), except maybe __VA_ARGS at the
@ -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, ...) do { } while (0)
# define _COUNT_IF(cond, file, line, ...) (cond)
# define _COUNT_GLITCH(file, line, ...) do { } while (0)
#endif