Skip to content

Commit 927dc33

Browse files
avargitster
authored andcommitted
advice.h: add missing __attribute__((format)) & fix usage
Add the missing __attribute__((format)) checking to advise_if_enabled(). This revealed a trivial issue introduced in b3b18d1 (advice: revamp advise API, 2020-03-02). We treated the argv[1] as a format string, but did not intend to do so. Let's use "%s" and pass argv[1] as an argument instead. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 75d31ce commit 927dc33

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ int advice_enabled(enum advice_type type);
9090
/**
9191
* Checks the visibility of the advice before printing.
9292
*/
93+
__attribute__((format (printf, 2, 3)))
9394
void advise_if_enabled(enum advice_type type, const char *advice, ...);
9495

9596
int error_resolve_conflict(const char *me);

t/helper/test-advise.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int cmd__advise_if_enabled(int argc, const char **argv)
1616
* selected here and in t0018 where this command is being
1717
* executed.
1818
*/
19-
advise_if_enabled(ADVICE_NESTED_TAG, argv[1]);
19+
advise_if_enabled(ADVICE_NESTED_TAG, "%s", argv[1]);
2020

2121
return 0;
2222
}

0 commit comments

Comments
 (0)