From ad006fe419efda47b0012347c5c2925f9a082101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Tue, 19 Mar 2019 17:13:46 +0000 Subject: trace2: NULL is not allowed for va_list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some compilers don't allow NULL to be passed for a va_list, and e.g. "gcc (Raspbian 6.3.0-18+rpi1+deb9u1) 6.3.0 20170516" errors out like this: trace2/tr2_tgt_event.c:193:18: error: invalid operands to binary && (have ‘int’ and ‘va_list {aka __va_list}’) if (fmt && *fmt && ap) { ^^ I couldn't find any hints that va_list and pointers can be mixed, and no hints that they can't either. Morten Welinder comments: "C99, Section 7.15, simply says that va_list "is an object type suitable for holding information needed by the macros va_start, va_end, and va_copy". So clearly not guaranteed to be mixable with pointers... The portable solution is to use "va_list" everywhere in the callchain. As a consequence, both trace2_region_enter_fl() and trace2_region_leave_fl() now take a variable argument list. Signed-off-by: Torsten Bögershausen Acked-by: Jeff Hostetler Signed-off-by: Junio C Hamano --- trace2.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'trace2.c') diff --git a/trace2.c b/trace2.c index ccccd4ef09..8bbad56887 100644 --- a/trace2.c +++ b/trace2.c @@ -548,10 +548,14 @@ void trace2_region_enter_printf_va_fl(const char *file, int line, } void trace2_region_enter_fl(const char *file, int line, const char *category, - const char *label, const struct repository *repo) + const char *label, const struct repository *repo, ...) { + va_list ap; + va_start(ap, repo); trace2_region_enter_printf_va_fl(file, line, category, label, repo, - NULL, NULL); + NULL, ap); + va_end(ap); + } void trace2_region_enter_printf_fl(const char *file, int line, @@ -621,10 +625,13 @@ void trace2_region_leave_printf_va_fl(const char *file, int line, } void trace2_region_leave_fl(const char *file, int line, const char *category, - const char *label, const struct repository *repo) + const char *label, const struct repository *repo, ...) { + va_list ap; + va_start(ap, repo); trace2_region_leave_printf_va_fl(file, line, category, label, repo, - NULL, NULL); + NULL, ap); + va_end(ap); } void trace2_region_leave_printf_fl(const char *file, int line, -- cgit v1.2.3