Skip to content

Commit e119095

Browse files
committed
MINOR: debug: explicitly permit the counter condition to be empty
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.
1 parent 8f28dbe commit e119095

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

include/haproxy/bug.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,11 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt HA_SECTION_S
209209
.func = __func__, \
210210
.line = _line, \
211211
.type = _type, \
212-
.desc = (sizeof("" __VA_ARGS__) > 1) ? \
213-
"\"" #_cond "\" [" __VA_ARGS__ "]" : \
214-
"\"" #_cond "\"", \
212+
.desc = (sizeof("" #_cond) > 1) ? \
213+
(sizeof("" __VA_ARGS__) > 1) ? \
214+
"\"" #_cond "\" [" __VA_ARGS__ "]" : \
215+
"\"" #_cond "\"" : \
216+
"" __VA_ARGS__, \
215217
.count = 0, \
216218
}; \
217219
HA_WEAK(__start_dbg_cnt); \

src/debug.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,9 +2312,10 @@ static int debug_iohandler_counters(struct appctx *appctx)
23122312
}
23132313

23142314
if (ptr->type < DBG_COUNTER_TYPES)
2315-
chunk_appendf(&trash, "%-10u %3s %s:%d %s(): %s\n",
2315+
chunk_appendf(&trash, "%-10u %3s %s:%d %s()%s%s\n",
23162316
ptr->count, bug_type[ptr->type],
2317-
name, ptr->line, ptr->func, ptr->desc);
2317+
name, ptr->line, ptr->func,
2318+
*ptr->desc ? ": " : "", ptr->desc);
23182319

23192320
if (applet_putchk(appctx, &trash) == -1) {
23202321
ctx->start = ptr;

0 commit comments

Comments
 (0)