git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bisect: remove check for fp and move the goto label after the fclose
@ 2022-12-16  0:43 Rose via GitGitGadget
  2022-12-16  1:03 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Rose via GitGitGadget @ 2022-12-16  0:43 UTC (permalink / raw)
  To: git; +Cc: Rose, Seija Kijin

From: Seija Kijin <doremylover123@gmail.com>

The fp check in these function are only relevant if goto has been taken.

Because of this, we should move the label so that fclose is not called.

This is because the goto is taken when fp is 0 anyway.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    bisect: remove check for fp and move the goto label after the fclose
    
    The fp check in these function are only relevant if goto has been taken.
    
    Because of this, we should move the label so that fclose is not called.
    
    This is because the goto is taken when fp is 0 anyway.
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1397%2FAtariDreams%2Ffclose-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1397/AtariDreams/fclose-v1
Pull-Request: https://github.com/git/git/pull/1397

 builtin/bisect.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/bisect.c b/builtin/bisect.c
index cc9483e8515..2e5dbc8be3b 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -316,9 +316,9 @@ static int bisect_write(const char *state, const char *rev,
 	if (!nolog)
 		fprintf(fp, "git bisect %s %s\n", state, rev);
 
+	fclose(fp);
+
 finish:
-	if (fp)
-		fclose(fp);
 	strbuf_release(&tag);
 	return res;
 }
@@ -484,9 +484,9 @@ static int get_terms(struct bisect_terms *terms)
 	strbuf_getline_lf(&str, fp);
 	terms->term_good = strbuf_detach(&str, NULL);
 
+	fclose(fp);
+
 finish:
-	if (fp)
-		fclose(fp);
 	strbuf_release(&str);
 	return res;
 }

base-commit: 57e2c6ebbe7108b35ba30184dcbcb6c34c929ad8
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bisect: remove check for fp and move the goto label after the fclose
  2022-12-16  0:43 [PATCH] bisect: remove check for fp and move the goto label after the fclose Rose via GitGitGadget
@ 2022-12-16  1:03 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2022-12-16  1:03 UTC (permalink / raw)
  To: Rose via GitGitGadget; +Cc: git, Seija Kijin

"Rose via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Seija Kijin <doremylover123@gmail.com>
>
> The fp check in these function are only relevant if goto has been taken.
>
> Because of this, we should move the label so that fclose is not called.
>
> This is because the goto is taken when fp is 0 anyway.

It may happen to be so with today's code, but for the health of the
code in the longer term, I do not think this patch is a good idea.
We may add more "check error and jump to the label to clean it up"
exit paths to these functions, and change to add such exit paths
would essentially need to revert this change.

By the way, I do not know if this is something GGG end-users can
fix, or requires a fix in GGG itself, but somebody keeps adding an
e-mail address in the @users.noreply.github.com domain to the Cc:
field of these patches.  For folks whose work is GitHub only, it
might be fine to declare "this user only has e-mail-address-looking
string but does not receive e-mail at all", but as working with GGG
is all about following e-mail based workflow, such an address should
be added to patch e-mails sent to the list this say.

Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-16  1:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-16  0:43 [PATCH] bisect: remove check for fp and move the goto label after the fclose Rose via GitGitGadget
2022-12-16  1:03 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).