Navigation Menu

Skip to content

Commit

Permalink
*.c static functions: add missing __attribute__((format))
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
avar authored and gitster committed Jul 13, 2021
1 parent d4ac305 commit 48ca53c
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions add-patch.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions builtin/am.c
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions builtin/bisect--helper.c
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions commit-graph.c
Expand Up @@ -2408,6 +2408,7 @@ int write_commit_graph(struct object_directory *odb,
#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;
Expand Down
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions contrib/credential/wincred/git-credential-wincred.c
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions gettext.c
Expand Up @@ -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];
Expand Down
3 changes: 3 additions & 0 deletions imap-send.c
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions mailmap.c
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions merge-ort.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions merge-recursive.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions midx.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ref-filter.c
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions sequencer.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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, ...)
{
Expand Down
1 change: 1 addition & 0 deletions server-info.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions worktree.c
Expand Up @@ -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;
Expand Down

0 comments on commit 48ca53c

Please sign in to comment.