]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: avoid the break in __BUG_ON()
authorWilly Tarreau <w@1wt.eu>
Tue, 11 Aug 2026 07:32:02 +0000 (09:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Aug 2026 15:43:30 +0000 (17:43 +0200)
Since the "break" statement irritates gcc, let's resort to the
opposite expression involving a compount expression to declare the
static counter. It seems to be doing the job well, and we're back
to the previous size (-63 kB from original).

include/haproxy/bug.h

index efabaab5f6769b9a33af05b8a0e49b12f5e3a6cf..20d6bd22c5a7c5c3d19723bf40f6cddbd01c4263 100644 (file)
@@ -416,16 +416,15 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt  HA_SECTION_S
                        msg = "\"" #cond "\" matched at " file ":" #line "\x1e" __VA_ARGS__; \
                else                                                    \
                        msg = "\"" #cond "\" matched at " file ":" #line; \
-               if (type == DBG_BUG_ONCE) {                             \
-                       static int __match_count_##line;                \
-                       if (_HA_ATOMIC_FETCH_ADD(&__match_count_##line, 1)) \
-                               break;                                  \
-               }                                                       \
-               complain(details, msg);                                 \
-               if (details & DBG_DET_FAT_FATL)                         \
-                       ABORT_NOW();                                    \
-               else if (details & DBG_DET_FAT_WARN)                    \
-                       ha_backtrace_to_stderr(0);                      \
+               if (type != DBG_BUG_ONCE ||                             \
+                   ({ static int __match_count_##line;                 \
+                      !_HA_ATOMIC_FETCH_ADD(&__match_count_##line, 1); })) { \
+                       complain(details, msg);                         \
+                       if (details & DBG_DET_FAT_FATL)                 \
+                               ABORT_NOW();                            \
+                       else if (details & DBG_DET_FAT_WARN)            \
+                               ha_backtrace_to_stderr(0);              \
+               }                                                       \
        } while (0)
 
 /* This one is equivalent except that it only emits the message once by