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

[PATCH] remote: initialize values that might not be set

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Jun 7, 2021, 12:39 UTC
Message-ID
<pull.974.git.1623069570553.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>

I noticed during an unrelated test with Valgrind that these variables might be left un-set by stat_tracking_info() in some cases. Initialize them so that a later branch upon their value is consistent.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
    remote: initialize values that might not be set
    
    A very minor fixup.
    
    Thanks, -Stolee
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-974%2Fderrickstolee%2Fremote-uninitialized-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-974/derrickstolee/remote-uninitialized-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/974
 remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/remote.c b/remote.c
index c3f85c17ca7c..a116392fb057 100644
--- a/remote.c
+++ b/remote.c
@@ -2101,7 +2101,7 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
 int format_tracking_info(struct branch *branch, struct strbuf *sb,
 			 enum ahead_behind_flags abf)
 {
-	int ours, theirs, sti;
+	int ours = 0, theirs = 0, sti = 0;
 	const char *full_base;
 	char *base;
 	int upstream_is_gone = 0;

base-commit: 71ca53e8125e36efbda17293c50027d31681a41f
-- 
gitgitgadget
Next: Johannes Schindelin
Message 1 of 6 in “remote: initialize values that might not be set”
  1. remote: initialize values that might not be setDerrick Stolee via GitGitGadget, Jun 7, 2021
  2. Johannes SchindelinJun 7, 2021
  3. Junio C HamanoJun 7, 2021
  4. Johannes SchindelinJun 10, 2021
  5. Junio C HamanoJun 11, 2021
  6. Derrick StoleeJun 11, 2021

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.