]> git.ipfire.org Git - thirdparty/git.git/commitdiff
*.c static functions: add missing __attribute__((format))
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 13 Jul 2021 08:05:18 +0000 (10:05 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Jul 2021 22:20:20 +0000 (15:20 -0700)
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>
16 files changed:
add-patch.c
builtin/am.c
builtin/bisect--helper.c
commit-graph.c
contrib/credential/osxkeychain/git-credential-osxkeychain.c
contrib/credential/wincred/git-credential-wincred.c
gettext.c
imap-send.c
mailmap.c
merge-ort.c
merge-recursive.c
midx.c
ref-filter.c
sequencer.c
server-info.c
worktree.c

index 2fad92ca373292f328d5e5de4584638faa7bbd45..8c41cdfe39be041e7d119737a83d754a06733649 100644 (file)
@@ -280,6 +280,7 @@ static void add_p_state_clear(struct add_p_state *s)
        clear_add_i_state(&s->s);
 }
 
+__attribute__((format (printf, 2, 3)))
 static void err(struct add_p_state *s, const char *fmt, ...)
 {
        va_list args;
index 0b2d886c81b775d4b36cd575669808b8fc98868a..0c2ad96b70eef408492987a8b358887cc56dcb9c 100644 (file)
@@ -210,6 +210,7 @@ static void write_state_bool(const struct am_state *state,
  * If state->quiet is false, calls fprintf(fp, fmt, ...), and appends a newline
  * at the end.
  */
+__attribute__((format (printf, 3, 4)))
 static void say(const struct am_state *state, FILE *fp, const char *fmt, ...)
 {
        va_list ap;
index 9d9540a0abfe20e4a725797ba7aad65eecfd5d92..f184eaeac6d0fd60ae8d255c458f6b873f2bd3cf 100644 (file)
@@ -117,6 +117,7 @@ static int write_in_file(const char *path, const char *mode, const char *format,
        return fclose(fp);
 }
 
+__attribute__((format (printf, 2, 3)))
 static int write_to_file(const char *path, const char *format, ...)
 {
        int res;
@@ -129,6 +130,7 @@ static int write_to_file(const char *path, const char *format, ...)
        return res;
 }
 
+__attribute__((format (printf, 2, 3)))
 static int append_to_file(const char *path, const char *format, ...)
 {
        int res;
index 2bcb4e0f89e839f7666a3c2cd85522ebcb9c596d..9179a3a6476b9e45f2913e577b3989dd0d44feed 100644 (file)
@@ -2408,6 +2408,7 @@ cleanup:
 #define VERIFY_COMMIT_GRAPH_ERROR_HASH 2
 static int verify_commit_graph_error;
 
+__attribute__((format (printf, 1, 2)))
 static void graph_report(const char *fmt, ...)
 {
        va_list ap;
index bcd3f575a3e38611a88a8a0fcd51d39b9edb1599..0b44a9b7cc6f2b859f4b5c42edc52f528bdde84e 100644 (file)
@@ -10,6 +10,7 @@ static char *username;
 static char *password;
 static UInt16 port;
 
+__attribute__((format (printf, 1, 2)))
 static void die(const char *err, ...)
 {
        char msg[4096];
index 5bdad41de1f834b0685390258161a9e749d0dca0..5091048f9c649f31f0c11c49f33a7e757043023a 100644 (file)
@@ -11,6 +11,7 @@
 
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
 
+__attribute__((format (printf, 1, 2)))
 static void die(const char *err, ...)
 {
        char msg[4096];
index af2413b47e85223536b63f90180dd4c0ac2404d3..bb5ba1fe7cc5979255fe79fd8dfc0085fc8df8f1 100644 (file)
--- a/gettext.c
+++ b/gettext.c
@@ -66,6 +66,7 @@ const char *get_preferred_languages(void)
 }
 
 #ifndef NO_GETTEXT
+__attribute__((format (printf, 1, 2)))
 static int test_vsnprintf(const char *fmt, ...)
 {
        char buf[26];
index bb085d66d10509214eae1994e430d6058955f7cf..ce5a0461a43ea9477b71b27aac6517b005f0e06a 100644 (file)
@@ -451,6 +451,7 @@ static int buffer_gets(struct imap_buffer *b, char **s)
        /* not reached */
 }
 
+__attribute__((format (printf, 1, 2)))
 static void imap_info(const char *msg, ...)
 {
        va_list va;
@@ -463,6 +464,7 @@ static void imap_info(const char *msg, ...)
        }
 }
 
+__attribute__((format (printf, 1, 2)))
 static void imap_warn(const char *msg, ...)
 {
        va_list va;
@@ -504,6 +506,7 @@ static char *next_arg(char **s)
        return ret;
 }
 
+__attribute__((format (printf, 3, 4)))
 static int nfsnprintf(char *buf, int blen, const char *fmt, ...)
 {
        int ret;
index d1f7c0d272d81ca00bfef33c80a02b9d7da997cf..462b3956340be0bb917f7bda2cf82bdc9d489b11 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -8,6 +8,7 @@
 #define debug_mm(...) fprintf(stderr, __VA_ARGS__)
 #define debug_str(X) ((X) ? (X) : "(none)")
 #else
+__attribute__((format (printf, 1, 2)))
 static inline void debug_mm(const char *format, ...) {}
 static inline const char *debug_str(const char *s) { return s; }
 #endif
index b954f7184a5f56743548326c318773ac487bdc01..955d1d0502779c30676ecdfb7980e3eefb6715a2 100644 (file)
@@ -529,6 +529,7 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
        renames->callback_data_nr = renames->callback_data_alloc = 0;
 }
 
+__attribute__((format (printf, 2, 3)))
 static int err(struct merge_options *opt, const char *err, ...)
 {
        va_list params;
index 4327e0cfa3314974482005ef22cb2d24f18e5191..5d54990af9a12a4a04100e1b4228d015c1638531 100644 (file)
@@ -167,6 +167,7 @@ static void flush_output(struct merge_options *opt)
        }
 }
 
+__attribute__((format (printf, 2, 3)))
 static int err(struct merge_options *opt, const char *err, ...)
 {
        va_list params;
diff --git a/midx.c b/midx.c
index 21d6a05e887283400ae0ee10dd06d62418021997..0956849e2a1c8ff571ac439bece8b12d737017c4 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -1162,6 +1162,7 @@ void clear_midx_file(struct repository *r)
 
 static int verify_midx_error;
 
+__attribute__((format (printf, 1, 2)))
 static void midx_report(const char *fmt, ...)
 {
        va_list ap;
index 4db0e40ff4c6251aa808738e1630db1e397956de..f45d3a1b26dbd04f1f288e1afa49596b09c38f54 100644 (file)
@@ -213,6 +213,7 @@ static int used_atom_cnt, need_tagged, need_symref;
  * Expand string, append it to strbuf *sb, then return error code ret.
  * Allow to save few lines of code.
  */
+__attribute__((format (printf, 3, 4)))
 static int strbuf_addf_ret(struct strbuf *sb, int ret, const char *fmt, ...)
 {
        va_list ap;
index c316d8374a7e437be5ef052b54d32d909a7e6d33..7f07cd00f3f20ab3dc0c508653ac28bdd8e8b8c1 100644 (file)
@@ -3521,6 +3521,7 @@ static int do_exec(struct repository *r, const char *command_line)
        return status;
 }
 
+__attribute__((format (printf, 2, 3)))
 static int safe_append(const char *filename, const char *fmt, ...)
 {
        va_list ap;
@@ -3598,6 +3599,7 @@ static int do_label(struct repository *r, const char *name, int len)
        return ret;
 }
 
+__attribute__((format (printf, 3, 4)))
 static const char *reflog_message(struct replay_opts *opts,
        const char *sub_action, const char *fmt, ...)
 {
index de0aa4498c6131da80fb9ef8afb061fc1b9aff7e..7701d7c20a12af53d2f91737f12f3dfb97ac59e9 100644 (file)
@@ -27,6 +27,7 @@ static int uic_is_stale(const struct update_info_ctx *uic)
        return uic->old_fp == NULL;
 }
 
+__attribute__((format (printf, 2, 3)))
 static int uic_printf(struct update_info_ctx *uic, const char *fmt, ...)
 {
        va_list ap;
index 237517baee675631d50020ba0d75853881010f6d..092a4f92ad250e6ab474b6528957cfcf18bb8fda 100644 (file)
@@ -265,6 +265,7 @@ const char *worktree_prune_reason(struct worktree *wt, timestamp_t expire)
 }
 
 /* convenient wrapper to deal with NULL strbuf */
+__attribute__((format (printf, 2, 3)))
 static void strbuf_addf_gently(struct strbuf *buf, const char *fmt, ...)
 {
        va_list params;