Skip to content

Commit ce359a4

Browse files
committed
Merge branch 'jc/varargs-attributes' into maint-2.45
Varargs functions that are unannotated as printf-like or execl-like have been annotated as such. * jc/varargs-attributes: __attribute__: add a few missing format attributes __attribute__: mark some functions with LAST_ARG_MUST_BE_NULL __attribute__: remove redundant attribute declaration for git_die_config() __attribute__: trace2_region_enter_printf() is like "printf"
2 parents b2a62b6 + 99c7de7 commit ce359a4

File tree

9 files changed

+11
-2
lines changed

9 files changed

+11
-2
lines changed

add-patch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ static void err(struct add_p_state *s, const char *fmt, ...)
300300
va_end(args);
301301
}
302302

303+
LAST_ARG_MUST_BE_NULL
303304
static void setup_child_process(struct add_p_state *s,
304305
struct child_process *cp, ...)
305306
{

attr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ struct attr_check {
190190
};
191191

192192
struct attr_check *attr_check_alloc(void);
193+
194+
LAST_ARG_MUST_BE_NULL
193195
struct attr_check *attr_check_initl(const char *, ...);
194196
struct attr_check *attr_check_dup(const struct attr_check *check);
195197

config.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2822,7 +2822,6 @@ void git_die_config_linenr(const char *key, const char *filename, int linenr)
28222822
key, filename, linenr);
28232823
}
28242824

2825-
NORETURN __attribute__((format(printf, 2, 3)))
28262825
void git_die_config(const char *key, const char *err, ...)
28272826
{
28282827
const struct string_list *values;

hook.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,6 @@ int run_hooks(const char *hook_name);
8686
* argument. These things will be used as positional arguments to the
8787
* hook. This function behaves like the old run_hook_le() API.
8888
*/
89+
LAST_ARG_MUST_BE_NULL
8990
int run_hooks_l(const char *hook_name, ...);
9091
#endif

mem-pool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ char *mem_pool_strndup(struct mem_pool *pool, const char *str, size_t len);
5050
/*
5151
* Allocate memory from the memory pool and format a string into it.
5252
*/
53+
__attribute__((format (printf, 2, 3)))
5354
char *mem_pool_strfmt(struct mem_pool *pool, const char *fmt, ...);
5455

5556
/*

run-command.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,8 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
17531753

17541754
if (do_trace2)
17551755
trace2_region_enter_printf(tr2_category, tr2_label, NULL,
1756-
"max:%d", opts->processes);
1756+
"max:%"PRIuMAX,
1757+
(uintmax_t)opts->processes);
17571758

17581759
pp_init(&pp, opts, &pp_sig);
17591760
while (1) {

scalar.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static void setup_enlistment_directory(int argc, const char **argv,
7070
strbuf_release(&path);
7171
}
7272

73+
LAST_ARG_MUST_BE_NULL
7374
static int run_git(const char *arg, ...)
7475
{
7576
struct child_process cmd = CHILD_PROCESS_INIT;
@@ -288,6 +289,7 @@ static int unregister_dir(void)
288289
}
289290

290291
/* printf-style interface, expects `<key>=<value>` argument */
292+
__attribute__((format (printf, 1, 2)))
291293
static int set_config(const char *fmt, ...)
292294
{
293295
struct strbuf buf = STRBUF_INIT;

trace2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ void trace2_region_enter_printf_va_fl(const char *file, int line,
390390
trace2_region_enter_printf_va_fl(__FILE__, __LINE__, (category), \
391391
(label), (repo), (fmt), (ap))
392392

393+
__attribute__((format (printf, 6, 7)))
393394
void trace2_region_enter_printf_fl(const char *file, int line,
394395
const char *category, const char *label,
395396
const struct repository *repo,

wt-status.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ void status_printf(struct wt_status *s, const char *color,
126126
va_end(ap);
127127
}
128128

129+
__attribute__((format (printf, 3, 4)))
129130
static void status_printf_more(struct wt_status *s, const char *color,
130131
const char *fmt, ...)
131132
{

0 commit comments

Comments
 (0)