]> git.scripts.mit.edu Git - git.git/commitdiff
use "sentinel" function attribute for variadic lists
authorJeff King <peff@peff.net>
Wed, 10 Jul 2013 00:19:12 +0000 (20:19 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Jul 2013 05:23:09 +0000 (22:23 -0700)
This attribute can help gcc notice when callers forget to
add a NULL sentinel to the end of the function. This is our
first use of the sentinel attribute, but we shouldn't need
to #ifdef for other compilers, as __attribute__ is already a
no-op on non-gcc-compatible compilers.

Suggested-by: Bert Wesarg <bert.wesarg@googlemail.com>
More-Spots-Found-By: Matt Kraai <kraai@ftbfs.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
argv-array.h
builtin/revert.c
exec_cmd.h
run-command.h

index 40248d424c31662a3a574cfea13635084feb14f5..e8057483afafe89fc4ee1fb29dd9c80ab8ba6c9d 100644 (file)
@@ -15,6 +15,7 @@ void argv_array_init(struct argv_array *);
 void argv_array_push(struct argv_array *, const char *);
 __attribute__((format (printf,2,3)))
 void argv_array_pushf(struct argv_array *, const char *fmt, ...);
+__attribute__((sentinel))
 void argv_array_pushl(struct argv_array *, ...);
 void argv_array_pop(struct argv_array *);
 void argv_array_clear(struct argv_array *);
index 0401fdb02cbbcb6ac885c82ee2850fb931fc54ba..b8b51746def851c86371e084abaa95a64599c66c 100644 (file)
@@ -54,6 +54,7 @@ static int option_parse_x(const struct option *opt,
        return 0;
 }
 
+__attribute__((sentinel))
 static void verify_opt_compatible(const char *me, const char *base_opt, ...)
 {
        const char *this_opt;
@@ -70,6 +71,7 @@ static void verify_opt_compatible(const char *me, const char *base_opt, ...)
                die(_("%s: %s cannot be used with %s"), me, this_opt, base_opt);
 }
 
+__attribute__((sentinel))
 static void verify_opt_mutually_compatible(const char *me, ...)
 {
        const char *opt1, *opt2 = NULL;
index e2b546b615e2806bf7d733099ca0ac7bcfaef823..307b55cbad460f62edc3a9e6399690e45bdc7b0f 100644 (file)
@@ -7,6 +7,7 @@ extern const char *git_exec_path(void);
 extern void setup_path(void);
 extern const char **prepare_git_cmd(const char **argv);
 extern int execv_git_cmd(const char **argv); /* NULL terminated */
+__attribute__((sentinel))
 extern int execl_git_cmd(const char *cmd, ...);
 extern const char *system_path(const char *path);
 
index 221ce331405933f6f097b7e2b51401b70097e4e2..0a47679c42f9d5b0d1a55efd0bb25c866fba8253 100644 (file)
@@ -46,6 +46,7 @@ int finish_command(struct child_process *);
 int run_command(struct child_process *);
 
 extern char *find_hook(const char *name);
+__attribute__((sentinel))
 extern int run_hook(const char *index_file, const char *name, ...);
 
 #define RUN_COMMAND_NO_STDIN 1