summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-06-29 00:53:18 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-29 00:53:18 +0200
commitce359a4dcccba8093fc09750ddd24d4be999f8af (patch)
tree3b55c9308641c981e244bc49281e4a90d0797a47
parentMerge branch 'ps/ci-fix-detection-of-ubuntu-20' into maint-2.45 (diff)
parent__attribute__: add a few missing format attributes (diff)
downloadgit-ce359a4dcccba8093fc09750ddd24d4be999f8af.tar.xz
git-ce359a4dcccba8093fc09750ddd24d4be999f8af.zip
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"
-rw-r--r--add-patch.c1
-rw-r--r--attr.h2
-rw-r--r--config.c1
-rw-r--r--hook.h1
-rw-r--r--mem-pool.h1
-rw-r--r--run-command.c3
-rw-r--r--scalar.c2
-rw-r--r--trace2.h1
-rw-r--r--wt-status.c1
9 files changed, 11 insertions, 2 deletions
diff --git a/add-patch.c b/add-patch.c
index 0997d4af73..b2fbd8cbf3 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -300,6 +300,7 @@ static void err(struct add_p_state *s, const char *fmt, ...)
va_end(args);
}
+LAST_ARG_MUST_BE_NULL
static void setup_child_process(struct add_p_state *s,
struct child_process *cp, ...)
{
diff --git a/attr.h b/attr.h
index 127998ae01..afa33ce3be 100644
--- a/attr.h
+++ b/attr.h
@@ -190,6 +190,8 @@ struct attr_check {
};
struct attr_check *attr_check_alloc(void);
+
+LAST_ARG_MUST_BE_NULL
struct attr_check *attr_check_initl(const char *, ...);
struct attr_check *attr_check_dup(const struct attr_check *check);
diff --git a/config.c b/config.c
index ae3652b08f..2766b149a0 100644
--- a/config.c
+++ b/config.c
@@ -2822,7 +2822,6 @@ void git_die_config_linenr(const char *key, const char *filename, int linenr)
key, filename, linenr);
}
-NORETURN __attribute__((format(printf, 2, 3)))
void git_die_config(const char *key, const char *err, ...)
{
const struct string_list *values;
diff --git a/hook.h b/hook.h
index 19ab9a5806..6511525aeb 100644
--- a/hook.h
+++ b/hook.h
@@ -86,5 +86,6 @@ int run_hooks(const char *hook_name);
* argument. These things will be used as positional arguments to the
* hook. This function behaves like the old run_hook_le() API.
*/
+LAST_ARG_MUST_BE_NULL
int run_hooks_l(const char *hook_name, ...);
#endif
diff --git a/mem-pool.h b/mem-pool.h
index d1c66413ec..321d86a63c 100644
--- a/mem-pool.h
+++ b/mem-pool.h
@@ -50,6 +50,7 @@ char *mem_pool_strndup(struct mem_pool *pool, const char *str, size_t len);
/*
* Allocate memory from the memory pool and format a string into it.
*/
+__attribute__((format (printf, 2, 3)))
char *mem_pool_strfmt(struct mem_pool *pool, const char *fmt, ...);
/*
diff --git a/run-command.c b/run-command.c
index 1b821042b4..ec2c12e98b 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1753,7 +1753,8 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
if (do_trace2)
trace2_region_enter_printf(tr2_category, tr2_label, NULL,
- "max:%d", opts->processes);
+ "max:%"PRIuMAX,
+ (uintmax_t)opts->processes);
pp_init(&pp, opts, &pp_sig);
while (1) {
diff --git a/scalar.c b/scalar.c
index 7234049a1b..5359b1a914 100644
--- a/scalar.c
+++ b/scalar.c
@@ -70,6 +70,7 @@ static void setup_enlistment_directory(int argc, const char **argv,
strbuf_release(&path);
}
+LAST_ARG_MUST_BE_NULL
static int run_git(const char *arg, ...)
{
struct child_process cmd = CHILD_PROCESS_INIT;
@@ -288,6 +289,7 @@ static int unregister_dir(void)
}
/* printf-style interface, expects `<key>=<value>` argument */
+__attribute__((format (printf, 1, 2)))
static int set_config(const char *fmt, ...)
{
struct strbuf buf = STRBUF_INIT;
diff --git a/trace2.h b/trace2.h
index 1f0669bbd2..19e04bf040 100644
--- a/trace2.h
+++ b/trace2.h
@@ -390,6 +390,7 @@ void trace2_region_enter_printf_va_fl(const char *file, int line,
trace2_region_enter_printf_va_fl(__FILE__, __LINE__, (category), \
(label), (repo), (fmt), (ap))
+__attribute__((format (printf, 6, 7)))
void trace2_region_enter_printf_fl(const char *file, int line,
const char *category, const char *label,
const struct repository *repo,
diff --git a/wt-status.c b/wt-status.c
index bdfc23e2ae..a12406eee0 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -126,6 +126,7 @@ void status_printf(struct wt_status *s, const char *color,
va_end(ap);
}
+__attribute__((format (printf, 3, 4)))
static void status_printf_more(struct wt_status *s, const char *color,
const char *fmt, ...)
{