{"thread":{"id":"47460","subject":"[FYI PATCH] t/helper/test-lazy-name-hash: fix compilation","startedAt":"2017-12-18T21:50:05Z","lastAt":"2017-12-22T20:02:46Z","messageCount":7,"participants":["Stefan Beller","Jonathan Tan","Jeff Hostetler","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"334993","messageId":"20171218214947.210042-1-sbeller@google.com","threadId":"47460","inReplyTo":null,"subject":"[FYI PATCH] t/helper/test-lazy-name-hash: fix compilation","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-12-18T21:49:47Z","receivedAt":"2017-12-18T21:50:05Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"I was compiling origin/master today with stricter compiler flags today\nand was greeted by\n\nt/helper/test-lazy-init-name-hash.c: In function ‘cmd_main’:\nt/helper/test-lazy-init-name-hash.c:172:5: error: ‘nr_threads_used’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n     printf(\"avg [size %8d] [single %f] %c [multi %f %d]\\n\",\n     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n         nr,\n         ~~~\n         (double)avg_single/1000000000,\n         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n         (avg_single < avg_multi ? '<' : '>'),\n         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n         (double)avg_multi/1000000000,\n         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n         nr_threads_used);\n         ~~~~~~~~~~~~~~~~\nt/helper/test-lazy-init-name-hash.c:115:6: note: ‘nr_threads_used’ was declared here\n  int nr_threads_used;\n      ^~~~~~~~~~~~~~~\n\nI do not see how we can arrive at that line without having `nr_threads_used`\ninitialized, as we'd have `count > 1`  (which asserts that we ran the\nloop above at least once, such that it *should* be initialized).\n\nI do not have time to dive into further analysis.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n t/helper/test-lazy-init-name-hash.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c\nindex 6368a89345..297fb01d61 100644\n--- a/t/helper/test-lazy-init-name-hash.c\n+++ b/t/helper/test-lazy-init-name-hash.c\n@@ -112,7 +112,7 @@ static void analyze_run(void)\n {\n \tuint64_t t1s, t1m, t2s, t2m;\n \tint cache_nr_limit;\n-\tint nr_threads_used;\n+\tint nr_threads_used = 0;\n \tint i;\n \tint nr;\n \n-- \n2.15.1.620.gb9897f4670-goog\n\n"},{"id":"335005","messageId":"20171218154310.aa62ea2c9f094b663393556e@google.com","threadId":"47460","inReplyTo":"20171218214947.210042-1-sbeller@google.com","subject":"Re: [FYI PATCH] t/helper/test-lazy-name-hash: fix compilation","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2017-12-18T23:43:10Z","receivedAt":"2017-12-18T23:43:18Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"On Mon, 18 Dec 2017 13:49:47 -0800\nStefan Beller <sbeller@google.com> wrote:\n\n> I was compiling origin/master today with stricter compiler flags today\n> and was greeted by\n> \n> t/helper/test-lazy-init-name-hash.c: In function ‘cmd_main’:\n> t/helper/test-lazy-init-name-hash.c:172:5: error: ‘nr_threads_used’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n>      printf(\"avg [size %8d] [single %f] %c [multi %f %d]\\n\",\n>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>          nr,\n>          ~~~\n>          (double)avg_single/1000000000,\n>          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>          (avg_single < avg_multi ? '<' : '>'),\n>          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>          (double)avg_multi/1000000000,\n>          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>          nr_threads_used);\n>          ~~~~~~~~~~~~~~~~\n> t/helper/test-lazy-init-name-hash.c:115:6: note: ‘nr_threads_used’ was declared here\n>   int nr_threads_used;\n>       ^~~~~~~~~~~~~~~\n> \n> I do not see how we can arrive at that line without having `nr_threads_used`\n> initialized, as we'd have `count > 1`  (which asserts that we ran the\n> loop above at least once, such that it *should* be initialized).\n\nYour analysis makes sense. (The compiler probably couldn't detect it because\n\"count\" is a static variable, not a local variable.)\n\n> --- a/t/helper/test-lazy-init-name-hash.c\n> +++ b/t/helper/test-lazy-init-name-hash.c\n> @@ -112,7 +112,7 @@ static void analyze_run(void)\n>  {\n>  \tuint64_t t1s, t1m, t2s, t2m;\n>  \tint cache_nr_limit;\n> -\tint nr_threads_used;\n> +\tint nr_threads_used = 0;\n>  \tint i;\n>  \tint nr;\n\nI agree that this is probably the best way to fix it. Another way might\nbe to omit printing out the number of threads used in the printf that\nprints the average statistics.\n\nThe best way is probably to not use so many global variables, but that\nis out of scope of this change.\n"},{"id":"335020","messageId":"39238da4-c2b8-050d-51e3-675f5515776e@jeffhostetler.com","threadId":"47460","inReplyTo":"20171218214947.210042-1-sbeller@google.com","subject":"Re: [FYI PATCH] t/helper/test-lazy-name-hash: fix compilation","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-12-19T14:19:13Z","receivedAt":"2017-12-19T14:19:19Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 12/18/2017 4:49 PM, Stefan Beller wrote:\n> I was compiling origin/master today with stricter compiler flags today\n> and was greeted by\n> \n> t/helper/test-lazy-init-name-hash.c: In function ‘cmd_main’:\n> t/helper/test-lazy-init-name-hash.c:172:5: error: ‘nr_threads_used’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n>       printf(\"avg [size %8d] [single %f] %c [multi %f %d]\\n\",\n>       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>           nr,\n>           ~~~\n>           (double)avg_single/1000000000,\n>           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>           (avg_single < avg_multi ? '<' : '>'),\n>           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>           (double)avg_multi/1000000000,\n>           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>           nr_threads_used);\n>           ~~~~~~~~~~~~~~~~\n> t/helper/test-lazy-init-name-hash.c:115:6: note: ‘nr_threads_used’ was declared here\n>    int nr_threads_used;\n>        ^~~~~~~~~~~~~~~\n> \n> I do not see how we can arrive at that line without having `nr_threads_used`\n> initialized, as we'd have `count > 1`  (which asserts that we ran the\n> loop above at least once, such that it *should* be initialized).\n> \n> I do not have time to dive into further analysis.\n> \n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>   t/helper/test-lazy-init-name-hash.c | 2 +-\n>   1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c\n> index 6368a89345..297fb01d61 100644\n> --- a/t/helper/test-lazy-init-name-hash.c\n> +++ b/t/helper/test-lazy-init-name-hash.c\n> @@ -112,7 +112,7 @@ static void analyze_run(void)\n>   {\n>   \tuint64_t t1s, t1m, t2s, t2m;\n>   \tint cache_nr_limit;\n> -\tint nr_threads_used;\n> +\tint nr_threads_used = 0;\n>   \tint i;\n>   \tint nr;\n\nAgreed. It should not be a problem.  Explicitly initializing it is fine.\n\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n\n\n"},{"id":"335116","messageId":"20171220222416.130872-1-sbeller@google.com","threadId":"47460","inReplyTo":"39238da4-c2b8-050d-51e3-675f5515776e@jeffhostetler.com","subject":"[PATCH] t/helper/test-lazy-name-hash: fix compilation","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-12-20T22:24:16Z","receivedAt":"2017-12-20T22:24:24Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"I was compiling origin/master today with the DEVELOPER compiler flags\ntoday and was greeted by\n\nt/helper/test-lazy-init-name-hash.c: In function ‘cmd_main’:\nt/helper/test-lazy-init-name-hash.c:172:5: error: ‘nr_threads_used’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n     printf(\"avg [size %8d] [single %f] %c [multi %f %d]\\n\",\n     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n         nr,\n         ~~~\n         (double)avg_single/1000000000,\n         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n         (avg_single < avg_multi ? '<' : '>'),\n         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n         (double)avg_multi/1000000000,\n         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n         nr_threads_used);\n         ~~~~~~~~~~~~~~~~\nt/helper/test-lazy-init-name-hash.c:115:6: note: ‘nr_threads_used’ was declared here\n  int nr_threads_used;\n      ^~~~~~~~~~~~~~~\n\nFix this issue by assigning 0 to 'nr_threads_used'.\n\nAcked-by: Jonathan Tan <jonathantanmy@google.com>\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\nSlightly reworded the commit message. I'd really like this patch to be included\nsuch that I can compile git with the DEVELOPER_CFLAGS flags.\n\n t/helper/test-lazy-init-name-hash.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c\nindex 6368a89345..297fb01d61 100644\n--- a/t/helper/test-lazy-init-name-hash.c\n+++ b/t/helper/test-lazy-init-name-hash.c\n@@ -112,7 +112,7 @@ static void analyze_run(void)\n {\n \tuint64_t t1s, t1m, t2s, t2m;\n \tint cache_nr_limit;\n-\tint nr_threads_used;\n+\tint nr_threads_used = 0;\n \tint i;\n \tint nr;\n \n-- \n2.15.1.620.gb9897f4670-goog\n\n"},{"id":"335177","messageId":"xmqq7etetyqo.fsf@gitster.mtv.corp.google.com","threadId":"47460","inReplyTo":"20171220222416.130872-1-sbeller@google.com","subject":"Re: [PATCH] t/helper/test-lazy-name-hash: fix compilation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-22T18:15:59Z","receivedAt":"2017-12-22T18:16:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> I was compiling origin/master today with the DEVELOPER compiler flags\n> today and was greeted by\n>\n> t/helper/test-lazy-init-name-hash.c: In function ‘cmd_main’:\n> t/helper/test-lazy-init-name-hash.c:172:5: error: ‘nr_threads_used’ may be used uninitialized in this function [-Werror=maybe-uninitialized]\n>      printf(\"avg [size %8d] [single %f] %c [multi %f %d]\\n\",\n>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>          nr,\n>          ~~~\n>          (double)avg_single/1000000000,\n>          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>          (avg_single < avg_multi ? '<' : '>'),\n>          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>          (double)avg_multi/1000000000,\n>          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>          nr_threads_used);\n>          ~~~~~~~~~~~~~~~~\n> t/helper/test-lazy-init-name-hash.c:115:6: note: ‘nr_threads_used’ was declared here\n>   int nr_threads_used;\n>       ^~~~~~~~~~~~~~~\n>\n> Fix this issue by assigning 0 to 'nr_threads_used'.\n>\n> Acked-by: Jonathan Tan <jonathantanmy@google.com>\n> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>\n> Slightly reworded the commit message. I'd really like this patch to be included\n> such that I can compile git with the DEVELOPER_CFLAGS flags.\n\nHeh; I do not think there particularly is much difference between\nstricter flags and DEVELOPER flags, but I would rather not lose the\nremoval of duplicated 'today' I did while I queued the previous one\n;-)\n\n>\n>  t/helper/test-lazy-init-name-hash.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c\n> index 6368a89345..297fb01d61 100644\n> --- a/t/helper/test-lazy-init-name-hash.c\n> +++ b/t/helper/test-lazy-init-name-hash.c\n> @@ -112,7 +112,7 @@ static void analyze_run(void)\n>  {\n>  \tuint64_t t1s, t1m, t2s, t2m;\n>  \tint cache_nr_limit;\n> -\tint nr_threads_used;\n> +\tint nr_threads_used = 0;\n>  \tint i;\n>  \tint nr;\n"},{"id":"335178","messageId":"CAGZ79kZ9rWYwzrG+fJu2neYVfHSgoR5TrkSmNf_EJeUm46QUvg@mail.gmail.com","threadId":"47460","inReplyTo":"xmqq7etetyqo.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] t/helper/test-lazy-name-hash: fix compilation","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-12-22T18:17:49Z","receivedAt":"2017-12-22T18:17:55Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"> Heh; I do not think there particularly is much difference between\n> stricter flags and DEVELOPER flags, but I would rather not lose the\n> removal of duplicated 'today' I did while I queued the previous one\n> ;-)\n\n\nI did not realize it was queued anywhere, please ignore then.\n"},{"id":"335187","messageId":"xmqqtvwir0nz.fsf@gitster.mtv.corp.google.com","threadId":"47460","inReplyTo":"CAGZ79kZ9rWYwzrG+fJu2neYVfHSgoR5TrkSmNf_EJeUm46QUvg@mail.gmail.com","subject":"Re: [PATCH] t/helper/test-lazy-name-hash: fix compilation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-22T20:02:40Z","receivedAt":"2017-12-22T20:02:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n>> Heh; I do not think there particularly is much difference between\n>> stricter flags and DEVELOPER flags, but I would rather not lose the\n>> removal of duplicated 'today' I did while I queued the previous one\n>> ;-)\n>\n>\n> I did not realize it was queued anywhere, please ignore then.\n\nI just did s/stricter/DEVELOPER/ on the one that have been queued.\nThanks.\n"}]}