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

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

From
Shawn O. Pearce <spearce@spearce.org>
Date
Sep 29, 2009, 16:40 UTC
Message-ID
<20090929164046.GB25756@spearce.org>
In-Reply-To
<1254206409-13256-1-git-send-email-gitster@pobox.com>
Junio C Hamano <gitster@pobox.com> wrote:
> 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.
...
Show 11 quoted lines
> 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))
Uh...

builtin-mailinfo.c: In function 'handle_commit_msg': builtin-mailinfo.c:788: error: void value not ignored as it ought to be

I think you mean to squash this in, and use fseek instead:
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 3306d9e..c90cd31 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -785,7 +785,7 @@ static int handle_commit_msg(struct strbuf *line)
 
 	if (use_scissors && is_scissors_line(line)) {
 		int i;
-		if (rewind(cmitmsg))
+		if (fseek(cmitmsg, 0L, SEEK_SET))
 			die_errno("Could not rewind output message file");
 		if (ftruncate(fileno(cmitmsg), 0))
 			die_errno("Could not truncate output message file at scissors");
-- 
Shawn.
Previous: Junio C Hamano
Message 3 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.