]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tools: add new macro DEFZERO to provide a default zero argument
authorWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2024 14:44:32 +0000 (15:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2024 19:13:41 +0000 (20:13 +0100)
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

index ad881ae8f06f5b8fc139cc6f5d728f2e876f2a44..34e2fd818f6f8e6d446adc6cc8dee157f1d99ccd 100644 (file)
  * 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() */