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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> 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.
...
> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]