From e57581d76d86329646c4ff788f98c8cb9c03981b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 19 Nov 2024 15:44:32 +0100 Subject: [PATCH] MINOR: tools: add new macro DEFZERO to provide a default zero argument This is the equivalent of DEFNULL except that it sets a zero value instead of a NULL for a missing argument. --- include/haproxy/tools-t.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/haproxy/tools-t.h b/include/haproxy/tools-t.h index ad881ae8f..34e2fd818 100644 --- a/include/haproxy/tools-t.h +++ b/include/haproxy/tools-t.h @@ -51,6 +51,12 @@ * use in macros arguments. */ #define DEFNULL(...) _FIRST_ARG(NULL, ##__VA_ARGS__, NULL) + +/* DEFZERO() returns either the argument as-is, or 0 if absent. This is for + * use in macros arguments. + */ +#define DEFZERO(...) _FIRST_ARG(NULL, ##__VA_ARGS__, 0) + #define _FIRST_ARG(a, b, ...) b /* options flags for parse_line() */