walker: let walker_say take arbitrary formats

We take a printf-style format and a single "char *" parameter, and the format must therefore have at most one "%s" in it. Besides being error-prone (and tickling -Wformat-nonliteral), this is unnecessarily restrictive. We can just provide the usual varargs interface. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jul 8, 2016 at 05:25 UTC fa262cac766d383c51e0ead04c62e114a79bd738
2 files changed +9 -4
walker.c
+7 -3
@@ -9,10 +9,14 @@
9
10 static unsigned char current_commit_sha1[20];
11
12 -void walker_say(struct walker *walker, const char *fmt, const char *hex)
12 +void walker_say(struct walker *walker, const char *fmt, ...)
13 {
14 - if (walker->get_verbosely)
15 - fprintf(stderr, fmt, hex);
14 + if (walker->get_verbosely) {
15 + va_list ap;
16 + va_start(ap, fmt);
17 + vfprintf(stderr, fmt, ap);
18 + va_end(ap);
19 + }
20 }
21
22 static void report_missing(const struct object *obj)
walker.h
+2 -1
@@ -19,7 +19,8 @@ struct walker {
19 };
20
21 /* Report what we got under get_verbosely */
22 -void walker_say(struct walker *walker, const char *, const char *);
22 +__attribute__((format (printf, 2, 3)))
23 +void walker_say(struct walker *walker, const char *fmt, ...);
24
25 /* Load pull targets from stdin */
26 int walker_targets_stdin(char ***target, const char ***write_ref);