Skip to content

Commit 48ca53c

Browse files
avargitster
authored andcommitted
*.c static functions: add missing __attribute__((format))
Add missing __attribute__((format)) function attributes to various "static" functions that take printf arguments. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d4ac305 commit 48ca53c

16 files changed

+20
-0
lines changed

add-patch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ static void add_p_state_clear(struct add_p_state *s)
280280
clear_add_i_state(&s->s);
281281
}
282282

283+
__attribute__((format (printf, 2, 3)))
283284
static void err(struct add_p_state *s, const char *fmt, ...)
284285
{
285286
va_list args;

builtin/am.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ static void write_state_bool(const struct am_state *state,
210210
* If state->quiet is false, calls fprintf(fp, fmt, ...), and appends a newline
211211
* at the end.
212212
*/
213+
__attribute__((format (printf, 3, 4)))
213214
static void say(const struct am_state *state, FILE *fp, const char *fmt, ...)
214215
{
215216
va_list ap;

builtin/bisect--helper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ static int write_in_file(const char *path, const char *mode, const char *format,
117117
return fclose(fp);
118118
}
119119

120+
__attribute__((format (printf, 2, 3)))
120121
static int write_to_file(const char *path, const char *format, ...)
121122
{
122123
int res;
@@ -129,6 +130,7 @@ static int write_to_file(const char *path, const char *format, ...)
129130
return res;
130131
}
131132

133+
__attribute__((format (printf, 2, 3)))
132134
static int append_to_file(const char *path, const char *format, ...)
133135
{
134136
int res;

commit-graph.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,6 +2408,7 @@ int write_commit_graph(struct object_directory *odb,
24082408
#define VERIFY_COMMIT_GRAPH_ERROR_HASH 2
24092409
static int verify_commit_graph_error;
24102410

2411+
__attribute__((format (printf, 1, 2)))
24112412
static void graph_report(const char *fmt, ...)
24122413
{
24132414
va_list ap;

contrib/credential/osxkeychain/git-credential-osxkeychain.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ static char *username;
1010
static char *password;
1111
static UInt16 port;
1212

13+
__attribute__((format (printf, 1, 2)))
1314
static void die(const char *err, ...)
1415
{
1516
char msg[4096];

contrib/credential/wincred/git-credential-wincred.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
1313

14+
__attribute__((format (printf, 1, 2)))
1415
static void die(const char *err, ...)
1516
{
1617
char msg[4096];

gettext.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const char *get_preferred_languages(void)
6666
}
6767

6868
#ifndef NO_GETTEXT
69+
__attribute__((format (printf, 1, 2)))
6970
static int test_vsnprintf(const char *fmt, ...)
7071
{
7172
char buf[26];

imap-send.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ static int buffer_gets(struct imap_buffer *b, char **s)
451451
/* not reached */
452452
}
453453

454+
__attribute__((format (printf, 1, 2)))
454455
static void imap_info(const char *msg, ...)
455456
{
456457
va_list va;
@@ -463,6 +464,7 @@ static void imap_info(const char *msg, ...)
463464
}
464465
}
465466

467+
__attribute__((format (printf, 1, 2)))
466468
static void imap_warn(const char *msg, ...)
467469
{
468470
va_list va;
@@ -504,6 +506,7 @@ static char *next_arg(char **s)
504506
return ret;
505507
}
506508

509+
__attribute__((format (printf, 3, 4)))
507510
static int nfsnprintf(char *buf, int blen, const char *fmt, ...)
508511
{
509512
int ret;

mailmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define debug_mm(...) fprintf(stderr, __VA_ARGS__)
99
#define debug_str(X) ((X) ? (X) : "(none)")
1010
#else
11+
__attribute__((format (printf, 1, 2)))
1112
static inline void debug_mm(const char *format, ...) {}
1213
static inline const char *debug_str(const char *s) { return s; }
1314
#endif

merge-ort.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
529529
renames->callback_data_nr = renames->callback_data_alloc = 0;
530530
}
531531

532+
__attribute__((format (printf, 2, 3)))
532533
static int err(struct merge_options *opt, const char *err, ...)
533534
{
534535
va_list params;

0 commit comments

Comments
 (0)