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

[PATCH] bisect: remove check for fp and move the goto label after the fclose

From
RGRose via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 16, 2022, 00:43 UTC
Message-ID
<pull.1397.git.git.1671151402532.gitgitgadget@gmail.com>
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
Next: Junio C Hamano
Message 1 of 2 in “bisect: remove check for fp and move the goto label after the fclose”
  1. bisect: remove check for fp and move the goto label after the fcloseRose via GitGitGadget, Dec 16, 2022
  2. Junio C HamanoDec 16, 2022

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.