*.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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Jul 13, 2021 at 10:05 UTC
48ca53cac4a5bee2dee3a5f3d6550753bf696d28
16 files changed
+20
add-patch.c
+1
@@ -280,6 +280,7 @@ static void add_p_state_clear(struct add_p_state *s)
280
clear_add_i_state(&s->s);
281
}
282
283
+__attribute__((format (printf, 2, 3)))
284
static void err(struct add_p_state *s, const char *fmt, ...)
285
{
286
va_list args;
builtin/am.c
+1
@@ -210,6 +210,7 @@ static void write_state_bool(const struct am_state *state,
210
* If state->quiet is false, calls fprintf(fp, fmt, ...), and appends a newline
211
* at the end.
212
*/
213
+__attribute__((format (printf, 3, 4)))
214
static void say(const struct am_state *state, FILE *fp, const char *fmt, ...)
215
{
216
va_list ap;
builtin/bisect--helper.c
+2
@@ -117,6 +117,7 @@ static int write_in_file(const char *path, const char *mode, const char *format,
117
return fclose(fp);
118
}
119
120
+__attribute__((format (printf, 2, 3)))
121
static int write_to_file(const char *path, const char *format, ...)
122
{
123
int res;
@@ -129,6 +130,7 @@ static int write_to_file(const char *path, const char *format, ...)
130
return res;
131
}
132
133
+__attribute__((format (printf, 2, 3)))
134
static int append_to_file(const char *path, const char *format, ...)
135
{
136
int res;
commit-graph.c
+1
@@ -2408,6 +2408,7 @@ cleanup:
2408
#define VERIFY_COMMIT_GRAPH_ERROR_HASH 2
2409
static int verify_commit_graph_error;
2410
2411
+__attribute__((format (printf, 1, 2)))
2412
static void graph_report(const char *fmt, ...)
2413
{
2414
va_list ap;
contrib/credential/osxkeychain/git-credential-osxkeychain.c
+1
@@ -10,6 +10,7 @@ static char *username;
10
static char *password;
11
static UInt16 port;
12
13
+__attribute__((format (printf, 1, 2)))
14
static void die(const char *err, ...)
15
{
16
char msg[4096];
contrib/credential/wincred/git-credential-wincred.c
+1
@@ -11,6 +11,7 @@
11
12
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
13
14
+__attribute__((format (printf, 1, 2)))
15
static void die(const char *err, ...)
16
{
17
char msg[4096];
gettext.c
+1
@@ -66,6 +66,7 @@ const char *get_preferred_languages(void)
66
}
67
68
#ifndef NO_GETTEXT
69
+__attribute__((format (printf, 1, 2)))
70
static int test_vsnprintf(const char *fmt, ...)
71
{
72
char buf[26];
imap-send.c
+3
@@ -451,6 +451,7 @@ static int buffer_gets(struct imap_buffer *b, char **s)
451
/* not reached */
452
}
453
454
+__attribute__((format (printf, 1, 2)))
455
static void imap_info(const char *msg, ...)
456
{
457
va_list va;
@@ -463,6 +464,7 @@ static void imap_info(const char *msg, ...)
464
}
465
}
466
467
+__attribute__((format (printf, 1, 2)))
468
static void imap_warn(const char *msg, ...)
469
{
470
va_list va;
@@ -504,6 +506,7 @@ static char *next_arg(char **s)
506
return ret;
507
}
508
509
+__attribute__((format (printf, 3, 4)))
510
static int nfsnprintf(char *buf, int blen, const char *fmt, ...)
511
{
512
int ret;
mailmap.c
+1
@@ -8,6 +8,7 @@
8
#define debug_mm(...) fprintf(stderr, __VA_ARGS__)
9
#define debug_str(X) ((X) ? (X) : "(none)")
10
#else
11
+__attribute__((format (printf, 1, 2)))
12
static inline void debug_mm(const char *format, ...) {}
13
static inline const char *debug_str(const char *s) { return s; }
14
#endif
merge-ort.c
+1
@@ -529,6 +529,7 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
529
renames->callback_data_nr = renames->callback_data_alloc = 0;
530
}
531
532
+__attribute__((format (printf, 2, 3)))
533
static int err(struct merge_options *opt, const char *err, ...)
534
{
535
va_list params;
merge-recursive.c
+1
@@ -167,6 +167,7 @@ static void flush_output(struct merge_options *opt)
167
}
168
}
169
170
+__attribute__((format (printf, 2, 3)))
171
static int err(struct merge_options *opt, const char *err, ...)
172
{
173
va_list params;
midx.c
+1
@@ -1162,6 +1162,7 @@ void clear_midx_file(struct repository *r)
1162
1163
static int verify_midx_error;
1164
1165
+__attribute__((format (printf, 1, 2)))
1166
static void midx_report(const char *fmt, ...)
1167
{
1168
va_list ap;
ref-filter.c
+1
@@ -213,6 +213,7 @@ static int used_atom_cnt, need_tagged, need_symref;
213
* Expand string, append it to strbuf *sb, then return error code ret.
214
* Allow to save few lines of code.
215
*/
216
+__attribute__((format (printf, 3, 4)))
217
static int strbuf_addf_ret(struct strbuf *sb, int ret, const char *fmt, ...)
218
{
219
va_list ap;
sequencer.c
+2
@@ -3521,6 +3521,7 @@ static int do_exec(struct repository *r, const char *command_line)
3521
return status;
3522
}
3523
3524
+__attribute__((format (printf, 2, 3)))
3525
static int safe_append(const char *filename, const char *fmt, ...)
3526
{
3527
va_list ap;
@@ -3598,6 +3599,7 @@ static int do_label(struct repository *r, const char *name, int len)
3599
return ret;
3600
}
3601
3602
+__attribute__((format (printf, 3, 4)))
3603
static const char *reflog_message(struct replay_opts *opts,
3604
const char *sub_action, const char *fmt, ...)
3605
{
server-info.c
+1
@@ -27,6 +27,7 @@ static int uic_is_stale(const struct update_info_ctx *uic)
27
return uic->old_fp == NULL;
28
}
29
30
+__attribute__((format (printf, 2, 3)))
31
static int uic_printf(struct update_info_ctx *uic, const char *fmt, ...)
32
{
33
va_list ap;
worktree.c
+1
@@ -265,6 +265,7 @@ const char *worktree_prune_reason(struct worktree *wt, timestamp_t expire)
265
}
266
267
/* convenient wrapper to deal with NULL strbuf */
268
+__attribute__((format (printf, 2, 3)))
269
static void strbuf_addf_gently(struct strbuf *buf, const char *fmt, ...)
270
{
271
va_list params;