From: Jeff King Date: Wed, 10 Jul 2013 00:23:28 +0000 (-0400) Subject: wt-status: use "format" function attribute for status_printf X-Git-Tag: v1.8.4-rc0~26^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8dd0ee823f1829a3aa228c3c73e31de5c89b5317;p=thirdparty%2Fgit.git wt-status: use "format" function attribute for status_printf These functions could benefit from the added compile-time safety of having the compiler check printf arguments. Unfortunately, we also sometimes pass an empty format string, which will cause false positives with -Wformat-zero-length. In this case, that warning is wrong because our function is not a no-op with an empty format: it may be printing colorized output along with a trailing newline. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/wt-status.h b/wt-status.h index 4121bc208d..fb7152e187 100644 --- a/wt-status.h +++ b/wt-status.h @@ -96,9 +96,9 @@ void wt_status_get_state(struct wt_status_state *state, int get_detached_from); void wt_shortstatus_print(struct wt_status *s); void wt_porcelain_print(struct wt_status *s); -void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...) - ; -void status_printf(struct wt_status *s, const char *color, const char *fmt, ...) - ; +__attribute__((format (printf, 3, 4))) +void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...); +__attribute__((format (printf, 3, 4))) +void status_printf(struct wt_status *s, const char *color, const char *fmt, ...); #endif /* STATUS_H */