git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: va_copy is not available on all systems.

From
Shawn O. Pearce <spearce@spearce.org>
Date
Aug 21, 2007, 03:38 UTC
Message-ID
<20070821033813.GF27913@spearce.org>
In-Reply-To
<20070820191509.GB5544@steel.home>
Alex Riesen <raa.lkml@gmail.com> wrote:
Show 7 quoted lines
> 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
Thanks Alex.  This feels more like the right solution to the problem.
I made a few minor edits, any comment?
 
-->8--
From: Alex Riesen <raa.lkml@gmail.com>
Subject: [PATCH] Avoid using va_copy in fast-import: it seems to be unportable.
[sp: minor change to use fputs, thus reducing the patch size]
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 fast-import.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 2d5224c..078079d 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");
@@ -397,7 +397,7 @@ static void write_crash_report(const char *err, va_list params)
 	fputc('\n', rpt);
 
 	fputs("fatal: ", rpt);
-	vfprintf(rpt, err, params);
+	fputs(err, rpt);
 	fputc('\n', rpt);
 
 	fputc('\n', rpt);
@@ -442,18 +442,17 @@ 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[2 * PATH_MAX];
 
-	va_copy(x_params, params);
+	vsnprintf(message, sizeof(message), err, params);
 	fputs("fatal: ", stderr);
-	vfprintf(stderr, err, params);
+	fputs(message, stderr);
 	fputc('\n', stderr);
 
 	if (!zombie) {
 		zombie = 1;
-		write_crash_report(err, x_params);
+		write_crash_report(message);
 	}
-	va_end(x_params);
 	exit(128);
 }
 
-- 
1.5.3.rc5.40.g2f82

-- 
Shawn.
Previous: Alex RiesenNext: Junio C Hamano
Message 4 of 6 in “va_copy is not available on all systems.”
  1. Johannes SixtAug 20, 2007
  2. Michael PooleAug 20, 2007
  3. Alex RiesenAug 20, 2007
  4. Shawn O. PearceAug 21, 2007
  5. Junio C HamanoAug 21, 2007
  6. Alex RiesenAug 21, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.