git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: Johannes Sixt <J.Sixt@eudaptics.com>
Cc: "Shawn O. Pearce" <spearce@spearce.org>,
	Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org
Subject: Re: va_copy is not available on all systems.
Date: Mon, 20 Aug 2007 21:15:09 +0200	[thread overview]
Message-ID: <20070820191509.GB5544@steel.home> (raw)
In-Reply-To: <46C99448.2AB33DFF@eudaptics.com>

Johannes Sixt, Mon, Aug 20, 2007 15:16:56 +0200:
> Since va_copy() must be provided by the compiler, we don't have a
> reasonable chance to provide a working definition in git_compat_util.h.

Maybe we don't have to:

Subject: [PATCH] Avoid using va_copy in fast-import: it seem to be unportable

diff --git a/fast-import.c b/fast-import.c
index 2d5224c..04948e9 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -375,7 +375,7 @@ static void write_branch_report(FILE *rpt, struct branch *b)
 	fputc('\n', rpt);
 }
 
-static void write_crash_report(const char *err, va_list params)
+static void write_crash_report(const char *err)
 {
 	char *loc = git_path("fast_import_crash_%d", getpid());
 	FILE *rpt = fopen(loc, "w");
@@ -396,9 +396,7 @@ static void write_crash_report(const char *err, va_list params)
 	fprintf(rpt, "    at %s\n", show_date(time(NULL), 0, DATE_LOCAL));
 	fputc('\n', rpt);
 
-	fputs("fatal: ", rpt);
-	vfprintf(rpt, err, params);
-	fputc('\n', rpt);
+	fprintf(rpt, "fatal: %s\n", err);
 
 	fputc('\n', rpt);
 	fputs("Most Recent Commands Before Crash\n", rpt);
@@ -442,18 +440,15 @@ static void write_crash_report(const char *err, va_list params)
 static NORETURN void die_nicely(const char *err, va_list params)
 {
 	static int zombie;
-	va_list x_params;
+	char message[BUFSIZ];
 
-	va_copy(x_params, params);
-	fputs("fatal: ", stderr);
-	vfprintf(stderr, err, params);
-	fputc('\n', stderr);
+	vsnprintf(message, sizeof(message), err, params);
+	fprintf(stderr, "fatal: %s\n", message);
 
 	if (!zombie) {
 		zombie = 1;
-		write_crash_report(err, x_params);
+		write_crash_report(message);
 	}
-	va_end(x_params);
 	exit(128);
 }
 

  parent reply	other threads:[~2007-08-20 19:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-20 13:16 va_copy is not available on all systems Johannes Sixt
2007-08-20 13:39 ` Michael Poole
2007-08-20 19:15 ` Alex Riesen [this message]
2007-08-21  3:38   ` Shawn O. Pearce
2007-08-21  4:53     ` Junio C Hamano
2007-08-21 18:37     ` Alex Riesen

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=20070820191509.GB5544@steel.home \
    --to=raa.lkml@gmail.com \
    --cc=J.Sixt@eudaptics.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=spearce@spearce.org \
    /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).