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

[PATCH 1/2] builtin-mailinfo.c: check error status from rewind and ftruncate

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 29, 2009, 06:40 UTC
Message-ID
<1254206409-13256-1-git-send-email-gitster@pobox.com>

A recent "cut at scissors" implementation rewinds and truncates the output file to store the message when it sees a scissors mark, but it did not check if these library calls succeeded.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-mailinfo.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index d498b1c..3306d9e 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -785,8 +785,10 @@ static int handle_commit_msg(struct strbuf *line)
 
 	if (use_scissors && is_scissors_line(line)) {
 		int i;
-		rewind(cmitmsg);
-		ftruncate(fileno(cmitmsg), 0);
+		if (rewind(cmitmsg))
+			die_errno("Could not rewind output message file");
+		if (ftruncate(fileno(cmitmsg), 0))
+			die_errno("Could not truncate output message file at scissors");
 		still_looking = 1;
 
 		/*
-- 
1.6.3
Next: Junio C Hamano
Message 1 of 3 in “builtin-mailinfo.c: check error status from rewind and ftruncate”
  1. 1/2 builtin-mailinfo.c: check error status from rewind and ftruncateJunio C Hamano, Sep 29, 2009
  2. 2/2 fast-import.c::validate_raw_date(): really validate the valueJunio C Hamano, Sep 29, 2009
  3. Shawn O. PearceSep 29, 2009

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.