From: Willy Tarreau Date: Tue, 11 Aug 2026 07:48:29 +0000 (+0200) Subject: MINOR: debug: rely on the __dbg_cnt_ counter for _BUG_ON_ONCE() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8aa8cd64e4ffd60ee7c8d95fea14b45cc0cd922;p=thirdparty%2Fhaproxy.git MINOR: debug: rely on the __dbg_cnt_ counter for _BUG_ON_ONCE() 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. --- diff --git a/include/haproxy/bug.h b/include/haproxy/bug.h index 585658288..7b476dac4 100644 --- a/include/haproxy/bug.h +++ b/include/haproxy/bug.h @@ -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__ : \