]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: rely on the __dbg_cnt_ counter for _BUG_ON_ONCE()
authorWilly Tarreau <w@1wt.eu>
Tue, 11 Aug 2026 07:48:29 +0000 (09:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Aug 2026 15:43:30 +0000 (17:43 +0200)
Since we already have a counter implemented when using DBG_COUNT(),
let's rely on this counter instead of declaring a local static one.
We always increment using a fetch_add() now, but regardless, this
reduces the code by 2 kB.

include/haproxy/bug.h

index 585658288e573f6f9a9d40854b669d54495e418e..7b476dac4b920afb75d5e55dbf66b4db644355d9 100644 (file)
@@ -362,10 +362,7 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt  HA_SECTION_S
                };                                                              \
                HA_WEAK(__start_dbg_cnt);                                       \
                HA_WEAK(__stop_dbg_cnt);                                        \
-               _HA_ATOMIC_INC(&__dbg_cnt_##_line.count);                       \
-               if (_type != DBG_BUG_ONCE ||                                    \
-                   ({ static int __match_count_##_line;                        \
-                      !_HA_ATOMIC_FETCH_ADD(&__match_count_##_line, 1); })) {  \
+               if (!_HA_ATOMIC_FETCH_ADD(&__dbg_cnt_##_line.count, 1) || _type != DBG_BUG_ONCE) { \
                        const char *msg =                                       \
                                (sizeof("" __VA_ARGS__) > 1) ?                  \
                                        "\"" #_cond "\" matched at " _file ":" #_line "\x1e" __VA_ARGS__ : \