]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: explicitly permit the counter condition to be empty
authorWilly Tarreau <w@1wt.eu>
Thu, 14 Nov 2024 07:47:00 +0000 (08:47 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 14 Nov 2024 07:47:00 +0000 (08:47 +0100)
In order to count new event types, we'll need to support empty conditions
so that we don't have to fake if (1) that would pollute the output. This
change checks if #cond is an empty string before concatenating it with
the optional var args, and avoids dumping the colon on the dump if the
whole description is empty.

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

index e708bcedf97c3169fb32d23fa331dd9a1251ec95..8183681abda5345f3192f91f9ebb588cc8ccc24f 100644 (file)
@@ -209,9 +209,11 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt  HA_SECTION_S
                        .func = __func__,                                       \
                        .line = _line,                                          \
                        .type = _type,                                          \
-                       .desc = (sizeof("" __VA_ARGS__) > 1) ?                  \
-                               "\"" #_cond "\" [" __VA_ARGS__ "]" :            \
-                               "\"" #_cond "\"",                               \
+                       .desc = (sizeof("" #_cond) > 1) ?                       \
+                                 (sizeof("" __VA_ARGS__) > 1) ?                \
+                                 "\"" #_cond "\" [" __VA_ARGS__ "]" :          \
+                                 "\"" #_cond "\"" :                            \
+                               "" __VA_ARGS__,                                 \
                        .count = 0,                                             \
                };                                                              \
                HA_WEAK(__start_dbg_cnt);                                       \
index 67d8ff9321692bce871e04b28b94c60c64307785..c4da8d7db6623abd5cb03e0331d6931fee1a9ff0 100644 (file)
@@ -2312,9 +2312,10 @@ static int debug_iohandler_counters(struct appctx *appctx)
                }
 
                if (ptr->type < DBG_COUNTER_TYPES)
-                       chunk_appendf(&trash, "%-10u %3s %s:%d %s()%s\n",
+                       chunk_appendf(&trash, "%-10u %3s %s:%d %s()%s%s\n",
                                      ptr->count, bug_type[ptr->type],
-                                     name, ptr->line, ptr->func, ptr->desc);
+                                     name, ptr->line, ptr->func,
+                                     *ptr->desc ? ": " : "", ptr->desc);
 
                if (applet_putchk(appctx, &trash) == -1) {
                        ctx->start = ptr;