Skip to content

Commit 8dd0ee8

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eccb614 commit 8dd0ee8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

wt-status.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
9696
void wt_shortstatus_print(struct wt_status *s);
9797
void wt_porcelain_print(struct wt_status *s);
9898

99-
void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...)
100-
;
101-
void status_printf(struct wt_status *s, const char *color, const char *fmt, ...)
102-
;
99+
__attribute__((format (printf, 3, 4)))
100+
void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...);
101+
__attribute__((format (printf, 3, 4)))
102+
void status_printf(struct wt_status *s, const char *color, const char *fmt, ...);
103103

104104
#endif /* STATUS_H */

0 commit comments

Comments
 (0)