Re: [PATCH] t/helper/test-lazy-name-hash: fix compilation
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 22, 2017, 18:15 UTC
- Message-ID
- <xmqq7etetyqo.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20171220222416.130872-1-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 30 quoted lines
> I was compiling origin/master today with the DEVELOPER 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;
> ^~~~~~~~~~~~~~~
>
> Fix this issue by assigning 0 to 'nr_threads_used'.
>
> Acked-by: Jonathan Tan <jonathantanmy@google.com>
> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>
> Slightly reworded the commit message. I'd really like this patch to be included
> such that I can compile git with the DEVELOPER_CFLAGS flags.Heh; I do not think there particularly is much difference between stricter flags and DEVELOPER flags, but I would rather not lose the removal of duplicated 'today' I did while I queued the previous one ;-)
Show 16 quoted lines
>
> 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;