am: fix condition check on fseek
PATCH 1/1 am: fix condition check on fseek
if fseek() is success, return value is 0
--- builtin/am.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
builtin/am.c +1 -1
@@ -589,7 +589,7 @@ static int is_mail(FILE *fp)regex_t regex;int ret =1 ; -if (fseek (fp,0L ,SEEK_SET )) +if (!fseek (fp,0L ,SEEK_SET ))die_errno (_ ("fseek failed" ));if (regcomp (®ex, header_regex,REG_NOSUB |REG_EXTENDED ))
Signature · 1 line
2.46.1
Quoted 21 lines · Ruffalo Lavoisier
if
fseek()is success, return value is 0Signed-off-by Ruffalo Lavoisier <[email protected]>--- builtin/am.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)builtin/am.c +1
-2@@ -589,7 +589,7 @@ static int is_mail(FILE *fp)regex_t regex;int ret =1 ; -if (fseek (fp,0L ,SEEK_SET )) +if (!fseek (fp,0L ,SEEK_SET ))die_errno (_ ("fseek failed" ));if (regcomp (®ex, header_regex,REG_NOSUB |REG_EXTENDED )) --
Quoted 1 line
2.46.1
I don’t get this change? The function returns false on success. true if it fails (not zero). You want the program to die if it returns non-zero.
It’s hard to wrap my head around… “false must mean “no errors” ”
If the original code has a bug then I don’t see how git-am(1) could work considering it presumably always checks ‘is_mail’.
Signature · 1 line
Kristoffer
Quoted 27 lines · Kristoffer Haugsbakk
Quoted 21 lines · Ruffalo Lavoisier
if
fseek()is success, return value is 0Signed-off-by Ruffalo Lavoisier <[email protected]>--- builtin/am.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)builtin/am.c +1
-2@@ -589,7 +589,7 @@ static int is_mail(FILE *fp)regex_t regex;int ret =1 ; -if (fseek (fp,0L ,SEEK_SET )) +if (!fseek (fp,0L ,SEEK_SET ))die_errno (_ ("fseek failed" ));if (regcomp (®ex, header_regex,REG_NOSUB |REG_EXTENDED )) --Quoted 1 line
2.46.1
I don’t get this change? The function returns false on success. true if it fails (not zero). You want the program to die if it returns non-zero.
Quoted 4 lines
It’s hard to wrap my head around… “false must mean “no errors” ”
If the original code has a bug then I don’t see how git-am(1) could work considering it presumably always checks ‘is_mail’.
Yeah, the proposed log message states a correct fact, but it is unclear how that justifies the change in the patch part of the message.