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

[PATCH next] fast-import: revert die_nicely() to vsnprintf

From
Thomas Rast <trast@student.ethz.ch>
Date
Jun 10, 2010, 19:55 UTC
Message-ID
<29df1a625a82bd2d3fcee92068b3a15f56435c66.1276199549.git.trast@student.ethz.ch>

ebaa79f (Make report() from usage.c public as vreportf() and use it., 2010-03-06) changed fast-import's die_nicely() to use vreportf().

This requires some more care though. First it forgot that we also need to reformat the message for the crash report. Second, vreportf() uses vsnprintf(), which does not call va_end(). This leaves the va_list passed to it in an undefined state. Therefore we need to make a copy of this va_list so that we can reuse it.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---

Another valgrind catch. I think that'll be the last one for today. Thanks for your attention.

 fast-import.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index c0728c2..1fa5de4 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -483,12 +483,14 @@ static void dump_marks(void);
 static NORETURN void die_nicely(const char *err, va_list params)
 {
 	static int zombie;
+	va_list saved_params;
+	va_copy(saved_params, params);
 
 	vreportf("fatal: ", err, params);
 
 	if (!zombie) {
 		char message[2 * PATH_MAX];
-
+		vsnprintf(message, sizeof(message), err, saved_params);
 		zombie = 1;
 		write_crash_report(message);
 		end_packfile();
-- 
1.7.1.561.g94582
Next: Erik Faye-Lund
Message 1 of 3 in “fast-import: revert die_nicely() to vsnprintf”
  1. fast-import: revert die_nicely() to vsnprintfThomas Rast, Jun 10, 2010
  2. Erik Faye-LundJun 11, 2010
  3. fast-import: die_nicely() back to vsnprintf (reverts part of ebaa79f)Thomas Rast, Jun 11, 2010

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.