Skip to content

Commit

Permalink
walker: let walker_say take arbitrary formats
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
peff authored and gitster committed Jul 8, 2016
1 parent 5c589a7 commit fa262ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions walker.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@

static unsigned char current_commit_sha1[20];

void walker_say(struct walker *walker, const char *fmt, const char *hex)
void walker_say(struct walker *walker, const char *fmt, ...)
{
if (walker->get_verbosely)
fprintf(stderr, fmt, hex);
if (walker->get_verbosely) {
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
}

static void report_missing(const struct object *obj)
Expand Down
3 changes: 2 additions & 1 deletion walker.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ struct walker {
};

/* Report what we got under get_verbosely */
void walker_say(struct walker *walker, const char *, const char *);
__attribute__((format (printf, 2, 3)))
void walker_say(struct walker *walker, const char *fmt, ...);

/* Load pull targets from stdin */
int walker_targets_stdin(char ***target, const char ***write_ref);
Expand Down

0 comments on commit fa262ca

Please sign in to comment.