Skip to content

Commit 74dea0e

Browse files
stefanbellergitster
authored andcommitted
t/helper/test-lazy-name-hash: fix compilation
I was compiling origin/master today with DEVELOPER compiler flags 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 uninitilized 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). Just clear the variable at the beginning of the function to squelch the warning. Signed-off-by: Stefan Beller <[email protected]> Acked-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 41b3eb4 commit 74dea0e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

t/helper/test-lazy-init-name-hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static void analyze_run(void)
112112
{
113113
uint64_t t1s, t1m, t2s, t2m;
114114
int cache_nr_limit;
115-
int nr_threads_used;
115+
int nr_threads_used = 0;
116116
int i;
117117
int nr;
118118

0 commit comments

Comments
 (0)