Re: [FYI PATCH] t/helper/test-lazy-name-hash: fix compilation
On 12/18/2017 4:49 PM, Stefan Beller wrote: 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/10, ~~ (avg_single < avg_multi ? '<' : '>'), ~ (double)avg_multi/10, ~ 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--- 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; Agreed. It should not be a problem. Explicitly initializing it is fine. Signed-off-by: Jeff Hostetler
Re: [FYI PATCH] t/helper/test-lazy-name-hash: fix compilation
On Mon, 18 Dec 2017 13:49:47 -0800 Stefan Bellerwrote: > 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/10, > ~~ > (avg_single < avg_multi ? '<' : '>'), > ~ > (double)avg_multi/10, > ~ > 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). Your analysis makes sense. (The compiler probably couldn't detect it because "count" is a static variable, not a local variable.) > --- 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; I agree that this is probably the best way to fix it. Another way might be to omit printing out the number of threads used in the printf that prints the average statistics. The best way is probably to not use so many global variables, but that is out of scope of this change.
RE: FYI
From: Denton, Cari-Lee Sent: July 6, 2014 12:44 AM To: Denton, Cari-Lee Subject: FYI You are picked, e-mail: mackenzie.glo...@yahoo.esmailto:mackenzie.glo...@yahoo.es for Info. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html