git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Jonathan Nieder <jrnieder@gmail.com>,
	Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH 3/8] trace: add trace_vprintf
Date: Thu, 24 Feb 2011 09:28:15 -0500	[thread overview]
Message-ID: <20110224142814.GC15477@sigill.intra.peff.net> (raw)
In-Reply-To: <20110224142308.GA15356@sigill.intra.peff.net>

This is a necessary cleanup to adding new types of trace
functions.

Signed-off-by: Jeff King <peff@peff.net>
---
 cache.h |    1 +
 trace.c |   14 +++++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/cache.h b/cache.h
index 4a758ba..08b23b2 100644
--- a/cache.h
+++ b/cache.h
@@ -1067,6 +1067,7 @@ extern void alloc_report(void);
 /* trace.c */
 __attribute__((format (printf, 1, 2)))
 extern void trace_printf(const char *format, ...);
+extern void trace_vprintf(const char *format, va_list ap);
 __attribute__((format (printf, 2, 3)))
 extern void trace_argv_printf(const char **argv, const char *format, ...);
 extern void trace_repo_setup(const char *prefix);
diff --git a/trace.c b/trace.c
index 745543c..6ad7788 100644
--- a/trace.c
+++ b/trace.c
@@ -62,10 +62,9 @@ static int get_trace_fd(int *need_close)
 static const char err_msg[] = "Could not trace into fd given by "
 	"GIT_TRACE environment variable";
 
-void trace_printf(const char *fmt, ...)
+void trace_vprintf(const char *fmt, va_list ap)
 {
 	struct strbuf buf = STRBUF_INIT;
-	va_list ap;
 	int fd, need_close = 0;
 
 	fd = get_trace_fd(&need_close);
@@ -73,10 +72,7 @@ void trace_printf(const char *fmt, ...)
 		return;
 
 	set_try_to_free_routine(NULL);	/* is never reset */
-	va_start(ap, fmt);
 	strbuf_addv(&buf, fmt, ap);
-	va_end(ap);
-
 	write_or_whine_pipe(fd, buf.buf, buf.len, err_msg);
 	strbuf_release(&buf);
 
@@ -84,6 +80,14 @@ void trace_printf(const char *fmt, ...)
 		close(fd);
 }
 
+void trace_printf(const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	trace_vprintf(fmt, ap);
+	va_end(ap);
+}
+
 void trace_argv_printf(const char **argv, const char *fmt, ...)
 {
 	struct strbuf buf = STRBUF_INIT;
-- 
1.7.2.5.25.g3bb93

  parent reply	other threads:[~2011-02-24 14:28 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-24 14:23 [PATCH/RFC 0/8] refactor trace code Jeff King
2011-02-24 14:26 ` [RFC/PATCH 1/8] compat: provide a fallback va_copy definition Jeff King
2011-02-24 15:57   ` Erik Faye-Lund
2011-03-08  8:33     ` [PATCH jk/strbuf-vaddf] compat: fall back on __va_copy if available Jonathan Nieder
2011-03-08 20:09       ` Junio C Hamano
2011-03-08 20:59         ` Jonathan Nieder
2011-02-24 20:33   ` [RFC/PATCH 1/8] compat: provide a fallback va_copy definition Jonathan Nieder
2011-02-24 14:27 ` [PATCH 2/8] strbuf: add strbuf_addv Jeff King
2011-02-24 15:05   ` Christian Couder
2011-02-24 15:07     ` Jeff King
2011-02-24 20:51   ` Jonathan Nieder
2011-02-24 14:28 ` Jeff King [this message]
2011-02-24 21:08   ` [PATCH 3/8] trace: add trace_vprintf Jonathan Nieder
2011-02-24 14:28 ` [PATCH 4/8] trace: refactor to support multiple env variables Jeff King
2011-02-24 18:25   ` Junio C Hamano
2011-02-24 19:02     ` Jeff King
2011-02-24 19:44       ` Junio C Hamano
2011-02-24 19:48         ` Jeff King
2011-02-24 20:50           ` Junio C Hamano
2011-02-24 21:23   ` Jonathan Nieder
2011-02-24 14:28 ` [PATCH 5/8] trace: factor out "do we want to trace" logic Jeff King
2011-02-24 15:07   ` Christian Couder
2011-02-24 14:29 ` [PATCH 6/8] trace: add trace_strbuf Jeff King
2011-02-24 14:30 ` [PATCH 7/8] add packet tracing debug code Jeff King
2011-02-24 21:44   ` Jonathan Nieder
2011-02-24 14:30 ` [PATCH 8/8] trace: give repo_setup trace its own key Jeff King
2011-02-24 15:59   ` Andreas Ericsson
2011-02-24 16:05     ` Jeff King
2011-02-24 20:01       ` Christian Couder
2011-02-24 21:49   ` Jonathan Nieder
2011-02-25  6:38     ` Nguyen Thai Ngoc Duy
2011-02-26  8:34   ` Junio C Hamano

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

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

  git send-email \
    --in-reply-to=20110224142814.GC15477@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=pclouds@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).