]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: debug: remove the now unused counter argument to complain()
authorWilly Tarreau <w@1wt.eu>
Mon, 10 Aug 2026 15:32:57 +0000 (17:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Aug 2026 15:43:30 +0000 (17:43 +0200)
Let's drop it before someone has the idea to use it again.

We take this opportunity for swapping complain()'s arguments which were
really poorly ordered since we're really passing a context first, so the
calls read better this way, particularly since we plan to add more.

This drops another 4 kB of code due to the number of calls.

include/haproxy/bug.h
src/debug.c

index 6e29688713532686fc53911d9adc7b203a57199a..5b408db23bde63593e4889458a476d42e5876e2e 100644 (file)
@@ -168,7 +168,7 @@ struct debug_count {
 #endif
 
 /* report a bug on stderr */
-void complain(int *counter, const char *msg, uint details);
+void complain(uint details, const char *msg);
 void ha_backtrace_to_stderr(int hint);
 
 /* Let's make DEBUG_STRESS equal to zero if not set or not valid, or to
@@ -301,7 +301,7 @@ static __attribute__((noinline,noreturn,unused)) void abort_with_line(uint line)
 
 #define __ABORT_NOW(file, line, ...) do {                              \
                if (sizeof("" __VA_ARGS__) > 1)                         \
-                       complain(NULL, "\nABORT at " file ":" #line ": " __VA_ARGS__ "\n", DBG_FATL_ABT); \
+                       complain(DBG_FATL_ABT, "\nABORT at " file ":" #line ": " __VA_ARGS__ "\n"); \
                ha_backtrace_to_stderr(1);                              \
                abort_with_line(__LINE__);                              \
        } while (0)
@@ -414,7 +414,7 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt  HA_SECTION_S
                        msg ="\n" pfx "condition \"" #cond "\" matched at " file ":" #line "" sfx "\n" __VA_ARGS__ "\n"; \
                else                                                    \
                        msg = "\n" pfx "condition \"" #cond "\" matched at " file ":" #line "" sfx "\n"; \
-               complain(NULL, msg, details);                           \
+               complain(details, msg);                                 \
                if (details & DBG_DET_FAT_FATL)                         \
                        ABORT_NOW();                                    \
                else if (details & DBG_DET_FAT_WARN)                    \
@@ -442,7 +442,7 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt  HA_SECTION_S
                        msg = "\n" pfx "condition \"" #cond "\" matched at " file ":" #line "" sfx "\n"; \
                if (_HA_ATOMIC_FETCH_ADD(&__match_count_##line, 1))     \
                        break;                                          \
-               complain(NULL, msg, details);                           \
+               complain(details, msg);                                 \
                if (details & DBG_DET_FAT_FATL)                         \
                        ABORT_NOW();                                    \
                else if (details & DBG_DET_FAT_WARN)                    \
index 84d48917caa9eeff25ba2f532b92c979bb5b5908..9c029837a10eeb9f64fbd9adb358cdbd925f49e0 100644 (file)
@@ -964,16 +964,12 @@ void ha_stuck_warning(void)
        DISGUISE(write(2, buf.area, buf.data));
 }
 
-/* Complain with message <msg> on stderr. If <counter> is not NULL, it is
- * atomically incremented, and the message is only printed when the counter
- * was zero, so that the message is only printed once. <details> is only
+/* Complain with message <msg> on stderr. <details> is only
  * checked on DBG_DET_TYP_BUG, and will taint the process either for a
  * bug or warn.
  */
-void complain(int *counter, const char *msg, uint details)
+void complain(uint details, const char *msg)
 {
-       if (counter && _HA_ATOMIC_FETCH_ADD(counter, 1))
-               return;
        DISGUISE(write(2, msg, strlen(msg)));
        if (details & (DBG_DET_TYP_BUG|DBG_DET_TYP_ABT))
                mark_tainted(TAINTED_BUG);