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

[PATCHv2 1/5] t/helper/test-lazy-name-hash: fix compilation

From
Stefan Beller <sbeller@google.com>
Date
Dec 27, 2017, 22:57 UTC
Message-ID
<20171227225705.73235-2-sbeller@google.com>
In-Reply-To
<20171227225705.73235-1-sbeller@google.com>

I was compiling origin/master today with stricter compiler flags today and was greeted by

t/helper/test-lazy-init-name-hash.c: In function ‘cmd_main’:
t/helper/test-lazy-init-name-hash.c:172:5: error: ‘nr_threads_used’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     printf("avg [size %8d] [single %f] %c [multi %f %d]\n",
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         nr,
         ~~~
         (double)avg_single/1000000000,
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         (avg_single < avg_multi ? '<' : '>'),
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         (double)avg_multi/1000000000,
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         nr_threads_used);
         ~~~~~~~~~~~~~~~~
t/helper/test-lazy-init-name-hash.c:115:6: note: ‘nr_threads_used’ was declared here
  int nr_threads_used;
      ^~~~~~~~~~~~~~~

I do not see how we can arrive at that line without having `nr_threads_used` initialized, as we'd have `count > 1` (which asserts that we ran the loop above at least once, such that it *should* be initialized).

I do not have time to dive into further analysis.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 t/helper/test-lazy-init-name-hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c
index 6368a89345..297fb01d61 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
@@ -112,7 +112,7 @@ static void analyze_run(void)
 {
 	uint64_t t1s, t1m, t2s, t2m;
 	int cache_nr_limit;
-	int nr_threads_used;
+	int nr_threads_used = 0;
 	int i;
 	int nr;
 
-- 
2.15.1.620.gb9897f4670-goog
Previous: Stefan BellerNext: Stefan Beller
Message 18 of 38 in “Fix --recurse-submodules for submodule worktree changes”
  1. 0/5 Fix --recurse-submodules for submodule worktree changesStefan Beller, Dec 19, 2017
  2. 1/5 t/lib-submodule-update.sh: clarify testStefan Beller, Dec 19, 2017
  3. 3/5 t/lib-submodule-update.sh: add new test for submodule internal changeStefan Beller, Dec 19, 2017
  4. Jonathan NiederDec 19, 2017
  5. Stefan BellerDec 19, 2017
  6. 2/5 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Dec 19, 2017
  7. Junio C HamanoDec 22, 2017
  8. Stefan BellerDec 27, 2017
  9. 4/5 unpack-trees: Fix same() for submodulesStefan Beller, Dec 19, 2017
  10. 5/5 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Dec 19, 2017
  11. Jonathan NiederDec 19, 2017
  12. Stefan BellerDec 19, 2017
  13. Jonathan NiederDec 19, 2017
  14. Jonathan NiederDec 20, 2017
  15. Stefan BellerDec 20, 2017
  16. Stefan BellerDec 20, 2017
  17. 0/5 Fix --recurse-submodules for submodule worktree changesStefan Beller, Dec 27, 2017
  18. 1/5 t/helper/test-lazy-name-hash: fix compilationStefan Beller, Dec 27, 2017
  19. 2/5 t/lib-submodule-update.sh: clarify testStefan Beller, Dec 27, 2017
  20. 3/5 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Dec 27, 2017
  21. 5/5 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Dec 27, 2017
  22. 4/5 unpack-trees: oneway_merge to update submodulesStefan Beller, Dec 27, 2017
  23. Junio C HamanoJan 2, 2018
  24. Stefan BellerJan 2, 2018
  25. 0/5 Fix --recurse-submodules for submodule worktree changesStefan Beller, Jan 3, 2018
  26. 1/5 t/helper/test-lazy-name-hash: fix compilationStefan Beller, Jan 3, 2018
  27. 2/5 t/lib-submodule-update.sh: clarify testStefan Beller, Jan 3, 2018
  28. 3/5 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Jan 3, 2018
  29. 5/5 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Jan 3, 2018
  30. 4/5 unpack-trees: oneway_merge to update submodulesStefan Beller, Jan 3, 2018
  31. Junio C HamanoJan 3, 2018
  32. Stefan BellerJan 3, 2018
  33. 0/4 Fix --recurse-submodules for submodule worktree changesStefan Beller, Jan 5, 2018
  34. 1/4 t/lib-submodule-update.sh: clarify testStefan Beller, Jan 5, 2018
  35. 2/4 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Jan 5, 2018
  36. 3/4 unpack-trees: oneway_merge to update submodulesStefan Beller, Jan 5, 2018
  37. 4/4 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Jan 5, 2018
  38. Junio C HamanoJan 9, 2018

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.