Add the LAST_ARG_MUST_BE_NULL macro
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>
Thu, 18 Jul 2013 20:02:12 +0000 (21:02 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Jul 2013 16:26:15 +0000 (09:26 -0700)
The sentinel function attribute is not understood by versions of
the gcc compiler prior to v4.0. At present, for earlier versions
of gcc, the build issues 108 warnings related to the unknown
attribute. In order to suppress the warnings, we conditionally
define the LAST_ARG_MUST_BE_NULL macro to provide the sentinel attribute
for gcc v4.0 and newer.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
argv-array.h
builtin/revert.c
exec_cmd.h
git-compat-util.h
run-command.h
index e8057483afafe89fc4ee1fb29dd9c80ab8ba6c9d..85ba438ac1e877fa865e5b4d2301733735fa5d03 100644 (file)
@@ -15,7 +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))
+LAST_ARG_MUST_BE_NULL
 void argv_array_pushl(struct argv_array *, ...);
 void argv_array_pop(struct argv_array *);
 void argv_array_clear(struct argv_array *);
index b8b51746def851c86371e084abaa95a64599c66c..1d2648b756907f467edbe1e206535009df4c65e8 100644 (file)
@@ -54,7 +54,7 @@ static int option_parse_x(const struct option *opt,
        return 0;
 }
 
-__attribute__((sentinel))
+LAST_ARG_MUST_BE_NULL
 static void verify_opt_compatible(const char *me, const char *base_opt, ...)
 {
        const char *this_opt;
@@ -71,7 +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))
+LAST_ARG_MUST_BE_NULL
 static void verify_opt_mutually_compatible(const char *me, ...)
 {
        const char *opt1, *opt2 = NULL;
index 307b55cbad460f62edc3a9e6399690e45bdc7b0f..e4c9702f02858973096f6ef0f41e5a572ff4d0db 100644 (file)
@@ -7,7 +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))
+LAST_ARG_MUST_BE_NULL
 extern int execl_git_cmd(const char *cmd, ...);
 extern const char *system_path(const char *path);
 
index e955bb5e8b3101cc8c753cf541beabf5cd037b39..10e3ba6bc87b8427ccf1eccb31c0bcbc532a669c 100644 (file)
@@ -295,6 +295,13 @@ extern char *gitbasename(char *);
 #endif
 #endif
 
+/* The sentinel attribute is valid from gcc version 4.0 */
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#define LAST_ARG_MUST_BE_NULL __attribute__((sentinel))
+#else
+#define LAST_ARG_MUST_BE_NULL
+#endif
+
 #include "compat/bswap.h"
 
 #ifdef USE_WILDMATCH
index 0a47679c42f9d5b0d1a55efd0bb25c866fba8253..6b985afd07a5b58ecadad8859ae90b3430ccb4c2 100644 (file)
@@ -46,7 +46,7 @@ int finish_command(struct child_process *);
 int run_command(struct child_process *);
 
 extern char *find_hook(const char *name);
-__attribute__((sentinel))
+LAST_ARG_MUST_BE_NULL
 extern int run_hook(const char *index_file, const char *name, ...);
 
 #define RUN_COMMAND_NO_STDIN 1