git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Matt Kraai <kraai@ftbfs.org>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: [PATCH 2/3] use "sentinel" function attribute for variadic lists
Date: Tue, 9 Jul 2013 20:19:12 -0400	[thread overview]
Message-ID: <20130710001911.GB19423@sigill.intra.peff.net> (raw)
In-Reply-To: <20130710001659.GA11643@sigill.intra.peff.net>

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>
---
 argv-array.h     | 1 +
 builtin/revert.c | 2 ++
 exec_cmd.h       | 1 +
 run-command.h    | 1 +
 4 files changed, 5 insertions(+)

diff --git a/argv-array.h b/argv-array.h
index 40248d4..e805748 100644
--- a/argv-array.h
+++ b/argv-array.h
@@ -15,6 +15,7 @@ void argv_array_pushf(struct argv_array *, const char *fmt, ...);
 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 *);
diff --git a/builtin/revert.c b/builtin/revert.c
index 0401fdb..b8b5174 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -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;
diff --git a/exec_cmd.h b/exec_cmd.h
index e2b546b..307b55c 100644
--- a/exec_cmd.h
+++ b/exec_cmd.h
@@ -7,6 +7,7 @@ extern int execv_git_cmd(const char **argv); /* NULL terminated */
 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);
 
diff --git a/run-command.h b/run-command.h
index 221ce33..0a47679 100644
--- a/run-command.h
+++ b/run-command.h
@@ -46,6 +46,7 @@ extern char *find_hook(const char *name);
 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
-- 
1.8.3.rc3.24.gec82cb9

  parent reply	other threads:[~2013-07-10  0:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09  5:18 [PATCH] remote-http: use argv-array Junio C Hamano
2013-07-09  6:05 ` Bert Wesarg
2013-07-09  6:38   ` Jeff King
2013-07-09 22:27     ` Matt Kraai
2013-07-10  0:16       ` Jeff King
2013-07-10  0:18         ` [PATCH 1/3] add missing "format" function attributes Jeff King
2013-07-10  0:19         ` Jeff King [this message]
2013-07-10  0:23         ` [PATCH 3/3] wt-status: use "format" function attribute for status_printf Jeff King
2013-07-10  5:26           ` Junio C Hamano
2013-07-10  5:28             ` Jeff King
2013-07-10  5:35               ` Junio C Hamano
2013-07-10  5:40                 ` Jeff King
2013-07-10  5:52                   ` Junio C Hamano
2013-07-10  6:11                     ` Jeff King
2013-07-10  6:17                       ` Junio C Hamano
2013-07-12 16:10               ` Junio C Hamano
2013-07-12 20:44                 ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130710001911.GB19423@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kraai@ftbfs.org \
    --subject='Re: [PATCH 2/3] use "sentinel" function attribute for variadic lists' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).