Message ID | 20250114104820.2613099-1-marcandre.lureau@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | plugins: fix -Werror=maybe-uninitialized false-positive | expand |
Hi Marc-André, On 1/14/25 02:48, marcandre.lureau@redhat.com wrote: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > ../contrib/plugins/cache.c:638:9: error: ‘l2_cache’ may be used uninitialized [-Werror=maybe-uninitialized] > 638 | append_stats_line(rep, l1_dmem_accesses, l1_dmisses, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Is a false-positive, since cores > 1, so the variable is set in the > above loop. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > contrib/plugins/cache.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c > index 512ef6776b..c2c274cfcd 100644 > --- a/contrib/plugins/cache.c > +++ b/contrib/plugins/cache.c > @@ -609,7 +609,7 @@ static int l2_cmp(gconstpointer a, gconstpointer b) > static void log_stats(void) > { > int i; > - Cache *icache, *dcache, *l2_cache; > + Cache *icache, *dcache, *l2_cache = NULL; > > g_autoptr(GString) rep = g_string_new("core #, data accesses, data misses," > " dmiss rate, insn accesses," It does not hurt to initialize it, even though it's a false positive. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Thanks, Pierrick
On 1/14/25 02:48, marcandre.lureau@redhat.com wrote: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > ../contrib/plugins/cache.c:638:9: error: ‘l2_cache’ may be used uninitialized [-Werror=maybe-uninitialized] > 638 | append_stats_line(rep, l1_dmem_accesses, l1_dmisses, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Is a false-positive, since cores > 1, so the variable is set in the > above loop. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > contrib/plugins/cache.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c > index 512ef6776b..c2c274cfcd 100644 > --- a/contrib/plugins/cache.c > +++ b/contrib/plugins/cache.c > @@ -609,7 +609,7 @@ static int l2_cmp(gconstpointer a, gconstpointer b) > static void log_stats(void) > { > int i; > - Cache *icache, *dcache, *l2_cache; > + Cache *icache, *dcache, *l2_cache = NULL; > > g_autoptr(GString) rep = g_string_new("core #, data accesses, data misses," > " dmiss rate, insn accesses," By the way, which compiler (version?) are you using? Just curious to check if we don't have any other false positives in the code base with it if it's a newer version.
Hi On Tue, Jan 14, 2025 at 8:00 PM Pierrick Bouvier <pierrick.bouvier@linaro.org> wrote: > > On 1/14/25 02:48, marcandre.lureau@redhat.com wrote: > > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > > > ../contrib/plugins/cache.c:638:9: error: ‘l2_cache’ may be used uninitialized [-Werror=maybe-uninitialized] > > 638 | append_stats_line(rep, l1_dmem_accesses, l1_dmisses, > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > Is a false-positive, since cores > 1, so the variable is set in the > > above loop. > > > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > > --- > > contrib/plugins/cache.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c > > index 512ef6776b..c2c274cfcd 100644 > > --- a/contrib/plugins/cache.c > > +++ b/contrib/plugins/cache.c > > @@ -609,7 +609,7 @@ static int l2_cmp(gconstpointer a, gconstpointer b) > > static void log_stats(void) > > { > > int i; > > - Cache *icache, *dcache, *l2_cache; > > + Cache *icache, *dcache, *l2_cache = NULL; > > > > g_autoptr(GString) rep = g_string_new("core #, data accesses, data misses," > > " dmiss rate, insn accesses," > > By the way, > > which compiler (version?) are you using? > Just curious to check if we don't have any other false positives in the > code base with it if it's a newer version. GCC v14.2.1 from fc41. I use '--enable-debug' '--enable-asan' '-Doptimization=g' '-Ddebug=true' in my configure flags. All targets do not compile with those flags. ASAN reports various errors during make test. Help welcome!
Hi Marc-André, I could successfully build all targets with gcc 14.2.0 (using a debian sid container) with ubsan and asan enabled, and with -O2. Pierrick On 1/14/25 22:40, Marc-André Lureau wrote: > Hi > > On Tue, Jan 14, 2025 at 8:00 PM Pierrick Bouvier > <pierrick.bouvier@linaro.org> wrote: >> >> On 1/14/25 02:48, marcandre.lureau@redhat.com wrote: >>> From: Marc-André Lureau <marcandre.lureau@redhat.com> >>> >>> ../contrib/plugins/cache.c:638:9: error: ‘l2_cache’ may be used uninitialized [-Werror=maybe-uninitialized] >>> 638 | append_stats_line(rep, l1_dmem_accesses, l1_dmisses, >>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> >>> Is a false-positive, since cores > 1, so the variable is set in the >>> above loop. >>> >>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> >>> --- >>> contrib/plugins/cache.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c >>> index 512ef6776b..c2c274cfcd 100644 >>> --- a/contrib/plugins/cache.c >>> +++ b/contrib/plugins/cache.c >>> @@ -609,7 +609,7 @@ static int l2_cmp(gconstpointer a, gconstpointer b) >>> static void log_stats(void) >>> { >>> int i; >>> - Cache *icache, *dcache, *l2_cache; >>> + Cache *icache, *dcache, *l2_cache = NULL; >>> >>> g_autoptr(GString) rep = g_string_new("core #, data accesses, data misses," >>> " dmiss rate, insn accesses," >> >> By the way, >> >> which compiler (version?) are you using? >> Just curious to check if we don't have any other false positives in the >> code base with it if it's a newer version. > > > GCC v14.2.1 from fc41. > I use '--enable-debug' '--enable-asan' '-Doptimization=g' > '-Ddebug=true' in my configure flags. > All targets do not compile with those flags. > ASAN reports various errors during make test. > > Help welcome! >
marcandre.lureau@redhat.com writes: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > ../contrib/plugins/cache.c:638:9: error: ‘l2_cache’ may be used uninitialized [-Werror=maybe-uninitialized] > 638 | append_stats_line(rep, l1_dmem_accesses, l1_dmisses, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Is a false-positive, since cores > 1, so the variable is set in the > above loop. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Queued to plugins/next, thanks.
diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c index 512ef6776b..c2c274cfcd 100644 --- a/contrib/plugins/cache.c +++ b/contrib/plugins/cache.c @@ -609,7 +609,7 @@ static int l2_cmp(gconstpointer a, gconstpointer b) static void log_stats(void) { int i; - Cache *icache, *dcache, *l2_cache; + Cache *icache, *dcache, *l2_cache = NULL; g_autoptr(GString) rep = g_string_new("core #, data accesses, data misses," " dmiss rate, insn accesses,"