[PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized

Eric Auger posted 1 patch 1 year, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20221207132439.635402-1-eric.auger@redhat.com
There is a newer version of this series
target/i386/ops_sse.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Eric Auger 1 year, 4 months ago
Initialize r0-3 to avoid compilation errors when
-Werror=maybe-uninitialized is used

../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2495 |     d->Q(3) = r3;
      |     ~~~~~~~~^~~~
../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2494 |     d->Q(2) = r2;
      |     ~~~~~~~~^~~~
../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2493 |     d->Q(1) = r1;
      |     ~~~~~~~~^~~~
../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2492 |     d->Q(0) = r0;
      |     ~~~~~~~~^~~~

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")

---

Am I the only one getting this? Or anything wrong in my setup.
---
 target/i386/ops_sse.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h
index 3cbc36a59d..b77071b8da 100644
--- a/target/i386/ops_sse.h
+++ b/target/i386/ops_sse.h
@@ -2451,7 +2451,7 @@ void glue(helper_vpgatherqq, SUFFIX)(CPUX86State *env,
 #if SHIFT >= 2
 void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s, uint32_t order)
 {
-    uint64_t r0, r1, r2, r3;
+    uint64_t r0 = 0, r1 = 0, r2 = 0, r3 = 0;
 
     switch (order & 3) {
     case 0:
-- 
2.37.3


Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Eric Auger 1 year, 4 months ago

On 12/7/22 14:24, Eric Auger wrote:
> Initialize r0-3 to avoid compilation errors when
> -Werror=maybe-uninitialized is used
>
> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>  2495 |     d->Q(3) = r3;
>       |     ~~~~~~~~^~~~
> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>  2494 |     d->Q(2) = r2;
>       |     ~~~~~~~~^~~~
> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>  2493 |     d->Q(1) = r1;
>       |     ~~~~~~~~^~~~
> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>  2492 |     d->Q(0) = r0;
>       |     ~~~~~~~~^~~~
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
>
> ---
>
> Am I the only one getting this? Or anything wrong in my setup.

With Stefan's correct address. Forgive me for the noise.

Eric
> ---
>  target/i386/ops_sse.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h
> index 3cbc36a59d..b77071b8da 100644
> --- a/target/i386/ops_sse.h
> +++ b/target/i386/ops_sse.h
> @@ -2451,7 +2451,7 @@ void glue(helper_vpgatherqq, SUFFIX)(CPUX86State *env,
>  #if SHIFT >= 2
>  void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s, uint32_t order)
>  {
> -    uint64_t r0, r1, r2, r3;
> +    uint64_t r0 = 0, r1 = 0, r2 = 0, r3 = 0;
>  
>      switch (order & 3) {
>      case 0:


Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Stefan Hajnoczi 1 year, 4 months ago
On Wed, 7 Dec 2022 at 08:31, Eric Auger <eric.auger@redhat.com> wrote:
> On 12/7/22 14:24, Eric Auger wrote:
> > Initialize r0-3 to avoid compilation errors when
> > -Werror=maybe-uninitialized is used
> >
> > ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
> > ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >  2495 |     d->Q(3) = r3;
> >       |     ~~~~~~~~^~~~
> > ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >  2494 |     d->Q(2) = r2;
> >       |     ~~~~~~~~^~~~
> > ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >  2493 |     d->Q(1) = r1;
> >       |     ~~~~~~~~^~~~
> > ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >  2492 |     d->Q(0) = r0;
> >       |     ~~~~~~~~^~~~
> >
> > Signed-off-by: Eric Auger <eric.auger@redhat.com>
> > Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
> >
> > ---
> >
> > Am I the only one getting this? Or anything wrong in my setup.
>
> With Stefan's correct address. Forgive me for the noise.

When is -Wmaybe-uninitialized used? QEMU's build system doesn't set
it. Unless it's automatically set by meson this must be a manual
--extra-cflags= option you set.

If you added it manually then let's fix this in 8.0 since it's not
tested/supported and very few people will see this issue.

Stefan
Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Eric Auger 1 year, 4 months ago
Hi Stefan,

On 12/7/22 15:09, Stefan Hajnoczi wrote:
> On Wed, 7 Dec 2022 at 08:31, Eric Auger <eric.auger@redhat.com> wrote:
>> On 12/7/22 14:24, Eric Auger wrote:
>>> Initialize r0-3 to avoid compilation errors when
>>> -Werror=maybe-uninitialized is used
>>>
>>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
>>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>  2495 |     d->Q(3) = r3;
>>>       |     ~~~~~~~~^~~~
>>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>  2494 |     d->Q(2) = r2;
>>>       |     ~~~~~~~~^~~~
>>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>  2493 |     d->Q(1) = r1;
>>>       |     ~~~~~~~~^~~~
>>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>  2492 |     d->Q(0) = r0;
>>>       |     ~~~~~~~~^~~~
>>>
>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
>>>
>>> ---
>>>
>>> Am I the only one getting this? Or anything wrong in my setup.
>> With Stefan's correct address. Forgive me for the noise.
> When is -Wmaybe-uninitialized used? QEMU's build system doesn't set
> it. Unless it's automatically set by meson this must be a manual
> --extra-cflags= option you set.

I am using this configure cmd line:

./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib/qemu
--target-list=x86_64-softmmu --docdir=/usr/share/doc/qemu --enable-kvm
--extra-cflags=-O --enable-trace-backends=log --python=/usr/bin/python3
--extra-cflags=-Wall --extra-cflags=-Wundef
--extra-cflags=-Wwrite-strings --extra-cflags=-Wmissing-prototypes
--extra-cflags=-fno-strict-aliasing --extra-cflags=-fno-common
--extra-cflags=-Werror=type-limits
>
> If you added it manually then let's fix this in 8.0 since it's not
> tested/supported and very few people will see this issue.

Thanks

Eric
>
> Stefan
>


Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Philippe Mathieu-Daudé 1 year, 4 months ago
On 7/12/22 15:33, Eric Auger wrote:
> On 12/7/22 15:09, Stefan Hajnoczi wrote:
>> On Wed, 7 Dec 2022 at 08:31, Eric Auger <eric.auger@redhat.com> wrote:
>>> On 12/7/22 14:24, Eric Auger wrote:
>>>> Initialize r0-3 to avoid compilation errors when
>>>> -Werror=maybe-uninitialized is used
>>>>
>>>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
>>>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>>   2495 |     d->Q(3) = r3;
>>>>        |     ~~~~~~~~^~~~
>>>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>>   2494 |     d->Q(2) = r2;
>>>>        |     ~~~~~~~~^~~~
>>>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>>   2493 |     d->Q(1) = r1;
>>>>        |     ~~~~~~~~^~~~
>>>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>>   2492 |     d->Q(0) = r0;
>>>>        |     ~~~~~~~~^~~~
>>>>
>>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
>>>>
>>>> ---
>>>>
>>>> Am I the only one getting this? Or anything wrong in my setup.
>>> With Stefan's correct address. Forgive me for the noise.
>> When is -Wmaybe-uninitialized used? QEMU's build system doesn't set
>> it. Unless it's automatically set by meson this must be a manual
>> --extra-cflags= option you set.
> 
> I am using this configure cmd line:
> 
> ./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib/qemu
> --target-list=x86_64-softmmu --docdir=/usr/share/doc/qemu --enable-kvm
> --extra-cflags=-O --enable-trace-backends=log --python=/usr/bin/python3
> --extra-cflags=-Wall --extra-cflags=-Wundef
> --extra-cflags=-Wwrite-strings --extra-cflags=-Wmissing-prototypes
> --extra-cflags=-fno-strict-aliasing --extra-cflags=-fno-common
> --extra-cflags=-Werror=type-limits
>>
>> If you added it manually then let's fix this in 8.0 since it's not
>> tested/supported and very few people will see this issue.
Please include the relevant meson output in the commit description, i.e.:

C compiler for the host machine: clang (clang 14.0.0 "Apple clang 
version 14.0.0 (clang-1400.0.29.202)")
C linker for the host machine: clang ld64 820.1

   Compilation
     host CPU                     : aarch64
     host endianness              : little
     C compiler                   : clang
     Host C compiler              : clang
     C++ compiler                 : c++
     Objective-C compiler         : clang
     CFLAGS                       : -ggdb 
-Werror=incompatible-function-pointer-types -O2 -g
     CXXFLAGS                     : -ggdb 
-Werror=incompatible-function-pointer-types -O2 -g
     OBJCFLAGS                    : -ggdb 
-Werror=incompatible-function-pointer-types -ggdb -O2 -g
     LDFLAGS                      : -ggdb 
-Werror=incompatible-function-pointer-types
     QEMU_CFLAGS                  : ...
     QEMU_CXXFLAGS                : ...
     QEMU_OBJCFLAGS               : ...
     QEMU_LDFLAGS                 : -fstack-protector-strong

Thanks,

Phil.


Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Eric Auger 1 year, 4 months ago

On 12/7/22 17:55, Philippe Mathieu-Daudé wrote:
> On 7/12/22 15:33, Eric Auger wrote:
>> On 12/7/22 15:09, Stefan Hajnoczi wrote:
>>> On Wed, 7 Dec 2022 at 08:31, Eric Auger <eric.auger@redhat.com> wrote:
>>>> On 12/7/22 14:24, Eric Auger wrote:
>>>>> Initialize r0-3 to avoid compilation errors when
>>>>> -Werror=maybe-uninitialized is used
>>>>>
>>>>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
>>>>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used
>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>   2495 |     d->Q(3) = r3;
>>>>>        |     ~~~~~~~~^~~~
>>>>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used
>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>   2494 |     d->Q(2) = r2;
>>>>>        |     ~~~~~~~~^~~~
>>>>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used
>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>   2493 |     d->Q(1) = r1;
>>>>>        |     ~~~~~~~~^~~~
>>>>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used
>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>   2492 |     d->Q(0) = r0;
>>>>>        |     ~~~~~~~~^~~~
>>>>>
>>>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>>>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
>>>>>
>>>>> ---
>>>>>
>>>>> Am I the only one getting this? Or anything wrong in my setup.
>>>> With Stefan's correct address. Forgive me for the noise.
>>> When is -Wmaybe-uninitialized used? QEMU's build system doesn't set
>>> it. Unless it's automatically set by meson this must be a manual
>>> --extra-cflags= option you set.
>>
>> I am using this configure cmd line:
>>
>> ./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib/qemu
>> --target-list=x86_64-softmmu --docdir=/usr/share/doc/qemu --enable-kvm
>> --extra-cflags=-O --enable-trace-backends=log --python=/usr/bin/python3
>> --extra-cflags=-Wall --extra-cflags=-Wundef
>> --extra-cflags=-Wwrite-strings --extra-cflags=-Wmissing-prototypes
>> --extra-cflags=-fno-strict-aliasing --extra-cflags=-fno-common
>> --extra-cflags=-Werror=type-limits
>>>
>>> If you added it manually then let's fix this in 8.0 since it's not
>>> tested/supported and very few people will see this issue.
> Please include the relevant meson output in the commit description, i.e.:
>
> C compiler for the host machine: clang (clang 14.0.0 "Apple clang
> version 14.0.0 (clang-1400.0.29.202)")
> C linker for the host machine: clang ld64 820.1
>
>   Compilation
>     host CPU                     : aarch64
>     host endianness              : little
>     C compiler                   : clang
>     Host C compiler              : clang
>     C++ compiler                 : c++
>     Objective-C compiler         : clang
>     CFLAGS                       : -ggdb
> -Werror=incompatible-function-pointer-types -O2 -g
>     CXXFLAGS                     : -ggdb
> -Werror=incompatible-function-pointer-types -O2 -g
>     OBJCFLAGS                    : -ggdb
> -Werror=incompatible-function-pointer-types -ggdb -O2 -g
>     LDFLAGS                      : -ggdb
> -Werror=incompatible-function-pointer-types
>     QEMU_CFLAGS                  : ...
>     QEMU_CXXFLAGS                : ...
>     QEMU_OBJCFLAGS               : ...
>     QEMU_LDFLAGS                 : -fstack-protector-strong
Here is the data:

C compiler for the host machine: cc -m64 -mcx16 (gcc 11.3.1 "cc (GCC)
11.3.1 20220421 (Red Hat 11.3.1-2)")
C linker for the host machine: cc -m64 -mcx16 ld.bfd 2.35.2-24

  Compilation
    host CPU                     : x86_64
    host endianness              : little
    C compiler                   : cc -m64 -mcx16
    Host C compiler              : cc -m64 -mcx16
    C++ compiler                 : c++ -m64 -mcx16
    CFLAGS                       : -O -Wall -Wundef -Wwrite-strings
-Wmissing-prototypes -fno-strict-aliasing -fno-common
-Werror=type-limits -O2 -g
    CXXFLAGS                     : -O -Wall -Wundef -Wwrite-strings
-Wmissing-prototypes -fno-strict-aliasing -fno-common
-Werror=type-limits -O2 -g
    LDFLAGS                      : -O -Wall -Wundef -Wwrite-strings
-Wmissing-prototypes -fno-strict-aliasing -fno-common -Werror=type-limits
    QEMU_CFLAGS                  : -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings
-Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv
-Wold-style-declaration -Wold-style-definition -Wtype-limits
-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers
-Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined
-Wimplicit-fallthrough=2 -Wno-missing-include-dirs
-Wno-shift-negative-value -Wno-psabi -fstack-protector-strong
    QEMU_CXXFLAGS                : -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef
-Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits
-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers
-Wempty-body -Wendif-labels -Wexpansion-to-defined
-Wimplicit-fallthrough=2 -Wno-missing-include-dirs
-Wno-shift-negative-value -Wno-psabi -fstack-protector-strong
    QEMU_OBJCFLAGS               :
    QEMU_LDFLAGS                 : -fstack-protector-strong -Wl,-z,relro
-Wl,-z,now

Eric

>
> Thanks,
>
> Phil.
>


Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Stefan Weil via 1 year, 4 months ago
Am 07.12.22 um 19:22 schrieb Eric Auger:
> 
> On 12/7/22 17:55, Philippe Mathieu-Daudé wrote:
>> On 7/12/22 15:33, Eric Auger wrote:
>>> On 12/7/22 15:09, Stefan Hajnoczi wrote:
>>>> On Wed, 7 Dec 2022 at 08:31, Eric Auger <eric.auger@redhat.com> wrote:
>>>>> On 12/7/22 14:24, Eric Auger wrote:
>>>>>> Initialize r0-3 to avoid compilation errors when
>>>>>> -Werror=maybe-uninitialized is used
>>>>>>
>>>>>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
>>>>>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used
>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>    2495 |     d->Q(3) = r3;
>>>>>>         |     ~~~~~~~~^~~~
>>>>>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used
>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>    2494 |     d->Q(2) = r2;
>>>>>>         |     ~~~~~~~~^~~~
>>>>>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used
>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>    2493 |     d->Q(1) = r1;
>>>>>>         |     ~~~~~~~~^~~~
>>>>>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used
>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>    2492 |     d->Q(0) = r0;
>>>>>>         |     ~~~~~~~~^~~~
>>>>>>
>>>>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>>>>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
>>>>>>
>>>>>> ---
>>>>>>
>>>>>> Am I the only one getting this? Or anything wrong in my setup.

Hi Eric,

no, you are not the only one. I regularly build with higher warning 
levels, for example with -Weverything on macOS, and get a much longer 
list which includes the mentioned warnings (see below).

The warnings for ops_sse.h are false positives, so I think no fix is 
needed for 7.2. The compiler is not clever enough to see that the switch 
statements handle all possible cases. It should be sufficient to replace 
`case 3` by `default` to help the compiler and fix the warning. Your fix 
might produce new compiler warnings because setting the variables to 0 
has no effect.

Cheers
Stefan

../block/mirror.c:1024:13: warning: variable 'iostatus' may be 
uninitialized when used here [-Wconditional-uninitialized]
../block/mirror.c:1498:20: warning: variable 'bounce_buf' may be 
uninitialized when used here [-Wconditional-uninitialized]
../block/nbd.c:1208:24: warning: variable 'request_ret' may be 
uninitialized when used here [-Wconditional-uninitialized]
../block/nbd.c:1266:24: warning: variable 'request_ret' may be 
uninitialized when used here [-Wconditional-uninitialized]
../block/nbd.c:1424:20: warning: variable 'request_ret' may be 
uninitialized when used here [-Wconditional-uninitialized]
../block/qcow2-snapshot.c:423:51: warning: variable 'snapshots_size' may 
be uninitialized when used here [-Wconditional-uninitialized]
../block/qcow2.c:3236:23: warning: variable 'cur_bytes' may be 
uninitialized when used here [-Wconditional-uninitialized]
../block/ssh.c:306:52: warning: variable 'server_hash_len' may be 
uninitialized when used here [-Wconditional-uninitialized]
../block/ssh.c:313:45: warning: variable 'pubkey_type' may be 
uninitialized when used here [-Wconditional-uninitialized]
../contrib/elf2dmp/main.c:138:17: warning: variable 'kwn' may be 
uninitialized when used here [-Wconditional-uninitialized]
../contrib/elf2dmp/main.c:138:22: warning: variable 'kwa' may be 
uninitialized when used here [-Wconditional-uninitialized]
../contrib/elf2dmp/main.c:138:27: warning: variable 
'KdpDataBlockEncoded' may be uninitialized when used here 
[-Wconditional-uninitialized]
../crypto/block-luks.c:844:29: warning: variable 'splitkeylen' may be 
uninitialized when used here [-Wconditional-uninitialized]
../disas/m68k.c:1513:47: warning: variable 'flval' may be uninitialized 
when used here [-Wconditional-uninitialized]
../dump/win_dump.c:105:18: warning: variable 'ptr64' may be 
uninitialized when used here [-Wconditional-uninitialized]
../dump/win_dump.c:105:26: warning: variable 'ptr32' may be 
uninitialized when used here [-Wconditional-uninitialized]
../gdbstub/gdbstub.c:1191:39: warning: variable 'pid' may be 
uninitialized when used here [-Wconditional-uninitialized]
../gdbstub/gdbstub.c:1209:36: warning: variable 'tid' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/9pfs/9p.c:1911:13: warning: variable 'fidst' may be uninitialized 
when used here [-Wconditional-uninitialized]
../hw/block/block.c:110:33: warning: variable 'bs' may be uninitialized 
when used here [-Wconditional-uninitialized]
../hw/core/generic-loader.c:160:23: warning: variable 'entry' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/i386/intel_iommu.c:323:12: warning: variable 'entry' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/ide/ahci.c:968:60: warning: variable 'tbl_entry_size' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/microblaze/boot.c:107:42: warning: variable 'fdt_size' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/net/rtl8139.c:1801:20: warning: variable 'buf2' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/nios2/boot.c:118:44: warning: variable 'fdt_size' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/nvram/fw_cfg.c:1254:40: warning: variable 'data' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/ppc/mac_oldworld.c:148:26: warning: variable 'bios_addr' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/ppc/spapr.c:274:55: warning: variable 'pa_size' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/riscv/microchip_pfsoc.c:609:54: warning: variable 
'firmware_load_addr' may be uninitialized when used here 
[-Wconditional-uninitialized]
../hw/s390x/css.c:553:9: warning: variable 'ret' may be uninitialized 
when used here [-Wconditional-uninitialized]
../hw/s390x/ipl.c:410:17: warning: variable 'devtype' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/s390x/s390-pci-inst.c:156:39: warning: variable 'res_code' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/sd/sdhci.c:844:17: warning: variable 'res' may be uninitialized 
when used here [-Wconditional-uninitialized]
../hw/sparc64/sun4u_iommu.c:159:66: warning: variable 'offset' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/xtensa/mx_pic.c:260:27: warning: variable 'oldv' may be 
uninitialized when used here [-Wconditional-uninitialized]
../hw/xtensa/mx_pic.c:260:33: warning: variable 'newv' may be 
uninitialized when used here [-Wconditional-uninitialized]
../migration/block.c:989:17: warning: variable 'ret' may be 
uninitialized when used here [-Wconditional-uninitialized]
../migration/migration.c:2847:17: warning: variable 'file' may be 
uninitialized when used here [-Wconditional-uninitialized]
../migration/ram.c:2088:24: warning: variable 'dirty' may be 
uninitialized when used here [-Wconditional-uninitialized]
../migration/savevm.c:721:30: warning: variable 'se' may be 
uninitialized when used here [-Wconditional-uninitialized]
../monitor/misc.c:1908:20: warning: variable 'snapshots' may be 
uninitialized when used here [-Wconditional-uninitialized]
../nbd/client-connection.c:419:9: warning: variable 'wait_co' may be 
uninitialized when used here [-Wconditional-uninitialized]
../net/socket.c:389:24: warning: variable 'saddr' may be uninitialized 
when used here [-Wconditional-uninitialized]
../net/tap-bsd.c:70:9: warning: variable 'fd' may be uninitialized when 
used here [-Wconditional-uninitialized]
../plugins/loader.c:406:17: warning: variable 'ctx' may be uninitialized 
when used here [-Wconditional-uninitialized]
../qemu-nbd.c:1175:22: warning: variable 'client_thread' may be 
uninitialized when used here [-Wconditional-uninitialized]
../softmmu/vl.c:1006:13: warning: variable 'opts' may be uninitialized 
when used here [-Wconditional-uninitialized]
../target/arm/helper.c:3299:17: warning: variable 'target_el' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/arm/m_helper.c:1727:37: warning: variable 'xpsr' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/arm/m_helper.c:1814:36: warning: variable 'shi' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/arm/m_helper.c:1814:48: warning: variable 'slo' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/arm/m_helper.c:1820:40: warning: variable 'fpscr' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/arm/translate-a64.c:10572:51: warning: variable 'rmode' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/arm/translate-a64.c:13225:51: warning: variable 'rmode' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/arm/translate-a64.c:8519:34: warning: variable 'tcg_src_hi' 
may be uninitialized when used here [-Wconditional-uninitialized]
../target/arm/translate.c:1590:50: warning: variable 'tmp' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/cris/mmu.c:201:33: warning: variable 'lo' may be uninitialized 
when used here [-Wconditional-uninitialized]
../target/i386/ops_sse.h:2492:15: warning: variable 'r0' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/i386/ops_sse.h:2493:15: warning: variable 'r1' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/i386/ops_sse.h:2494:15: warning: variable 'r2' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/i386/ops_sse.h:2495:15: warning: variable 'r3' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/m68k/softfloat.c:825:44: warning: variable 'm1' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1251:10: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1269:10: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1493:10: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1516:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1517:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1518:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1519:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1520:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1521:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1522:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1523:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1524:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1525:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1526:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1527:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1680:10: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:1954:10: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:2039:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:2040:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:2061:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:2062:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:2063:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:2064:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:2065:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:2066:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:2945:10: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:2956:10: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:2987:10: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:3063:10: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:967:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:968:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/int_helper.c:969:1: warning: variable 'result' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/ppc/mmu-radix64.c:548:20: warning: variable 'pte' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/ioinst.c:364:52: warning: variable 'irb_len' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/mem_helper.c:2978:12: warning: variable 'cc' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:1023:26: warning: variable 'vxc' 
may be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:132:26: warning: variable 'vxc' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:156:26: warning: variable 'vxc' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:278:26: warning: variable 'vxc' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:301:26: warning: variable 'vxc' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:439:26: warning: variable 'vxc' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:471:26: warning: variable 'vxc' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:551:26: warning: variable 'vxc' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:592:26: warning: variable 'vxc' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:635:26: warning: variable 'vxc' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:659:26: warning: variable 'vxc' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_fpu_helper.c:961:26: warning: variable 'vxc' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_helper.c:189:25: warning: variable 'tmp' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_helper.c:89:1: warning: variable 'tmp' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_helper.c:90:1: warning: variable 'tmp' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_helper.c:91:1: warning: variable 'tmp' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_int_helper.c:556:25: warning: variable 'tmp' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/s390x/tcg/vec_int_helper.c:606:25: warning: variable 'tmp' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/xtensa/translate.c:1074:51: warning: variable 'resource' may 
be uninitialized when used here [-Wconditional-uninitialized]
../target/xtensa/translate.c:1092:35: warning: variable 'temp' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/xtensa/translate.c:936:72: warning: variable 'rf' may be 
uninitialized when used here [-Wconditional-uninitialized]
../target/xtensa/xtensa-semi.c:297:17: warning: variable 'rc' may be 
uninitialized when used here [-Wconditional-uninitialized]
../tests/fp/berkeley-softfloat-3/source/s_shiftRightJam256M.c:117:10: 
warning: variable 'ptr' may be uninitialized when used here 
[-Wconditional-uninitialized]
../tests/fp/berkeley-testfloat-3/source/slowfloat.c:1015:13: warning: 
variable 'uiZ' may be uninitialized when used here 
[-Wconditional-uninitialized]
../tests/fp/berkeley-testfloat-3/source/slowfloat.c:742:13: warning: 
variable 'uiZ' may be uninitialized when used here 
[-Wconditional-uninitialized]
../tests/fp/berkeley-testfloat-3/source/slowfloat.c:878:13: warning: 
variable 'uiZ' may be uninitialized when used here 
[-Wconditional-uninitialized]
../tests/qtest/boot-sector.c:169:21: warning: variable 'signature' may 
be uninitialized when used here [-Wconditional-uninitialized]
../tests/qtest/prom-env-test.c:43:21: warning: variable 'signature' may 
be uninitialized when used here [-Wconditional-uninitialized]
../tests/unit/test-bdrv-drain.c:1022:21: warning: variable 'ret' may be 
uninitialized when used here [-Wconditional-uninitialized]
../tests/unit/test-block-iothread.c:772:14: warning: variable 'job' may 
be uninitialized when used here [-Wconditional-uninitialized]
../ui/vnc-enc-tight.c:416:1: warning: variable 'ci' may be uninitialized 
when used here [-Wconditional-uninitialized]
../ui/vnc-enc-tight.c:417:1: warning: variable 'ci' may be uninitialized 
when used here [-Wconditional-uninitialized]
../ui/vnc-enc-tight.c:418:1: warning: variable 'ci' may be uninitialized 
when used here [-Wconditional-uninitialized]
../util/iov.c:469:52: warning: variable 'mid_head' may be uninitialized 
when used here [-Wconditional-uninitialized]
../util/iov.c:471:36: warning: variable 'mid_tail' may be uninitialized 
when used here [-Wconditional-uninitialized]
../util/qemu-timer.c:198:12: warning: variable 'expire_time' may be 
uninitialized when used here [-Wconditional-uninitialized]
../util/qemu-timer.c:236:13: warning: variable 'expire_time' may be 
uninitialized when used here [-Wconditional-uninitialized]
../util/qemu-timer.c:476:9: warning: variable 'rearm' may be 
uninitialized when used here [-Wconditional-uninitialized]

Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Eric Auger 1 year, 4 months ago
Hi Stefan,

On 12/7/22 20:11, Stefan Weil via wrote:
> Am 07.12.22 um 19:22 schrieb Eric Auger:
>>
>> On 12/7/22 17:55, Philippe Mathieu-Daudé wrote:
>>> On 7/12/22 15:33, Eric Auger wrote:
>>>> On 12/7/22 15:09, Stefan Hajnoczi wrote:
>>>>> On Wed, 7 Dec 2022 at 08:31, Eric Auger <eric.auger@redhat.com>
>>>>> wrote:
>>>>>> On 12/7/22 14:24, Eric Auger wrote:
>>>>>>> Initialize r0-3 to avoid compilation errors when
>>>>>>> -Werror=maybe-uninitialized is used
>>>>>>>
>>>>>>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
>>>>>>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used
>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>    2495 |     d->Q(3) = r3;
>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used
>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>    2494 |     d->Q(2) = r2;
>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used
>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>    2493 |     d->Q(1) = r1;
>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used
>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>    2492 |     d->Q(0) = r0;
>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>>
>>>>>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>>>>>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
>>>>>>>
>>>>>>> ---
>>>>>>>
>>>>>>> Am I the only one getting this? Or anything wrong in my setup.
>
> Hi Eric,
>
> no, you are not the only one. I regularly build with higher warning
> levels, for example with -Weverything on macOS, and get a much longer
> list which includes the mentioned warnings (see below).

thanks! Interesting to see the exhaustive list below and your stats
sorted by warning category.
>
> The warnings for ops_sse.h are false positives, so I think no fix is
> needed for 7.2. The compiler is not clever enough to see that the
> switch statements handle all possible cases. It should be sufficient
> to replace `case 3` by `default` to help the compiler and fix the
> warning. Your fix might produce new compiler warnings because setting
> the variables to 0 has no effect.
OK. I will respin according to your suggestion for 8.0.

Eric
>
> Cheers
> Stefan
>
> ../block/mirror.c:1024:13: warning: variable 'iostatus' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../block/mirror.c:1498:20: warning: variable 'bounce_buf' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../block/nbd.c:1208:24: warning: variable 'request_ret' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../block/nbd.c:1266:24: warning: variable 'request_ret' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../block/nbd.c:1424:20: warning: variable 'request_ret' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../block/qcow2-snapshot.c:423:51: warning: variable 'snapshots_size'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../block/qcow2.c:3236:23: warning: variable 'cur_bytes' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../block/ssh.c:306:52: warning: variable 'server_hash_len' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../block/ssh.c:313:45: warning: variable 'pubkey_type' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../contrib/elf2dmp/main.c:138:17: warning: variable 'kwn' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../contrib/elf2dmp/main.c:138:22: warning: variable 'kwa' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../contrib/elf2dmp/main.c:138:27: warning: variable
> 'KdpDataBlockEncoded' may be uninitialized when used here
> [-Wconditional-uninitialized]
> ../crypto/block-luks.c:844:29: warning: variable 'splitkeylen' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../disas/m68k.c:1513:47: warning: variable 'flval' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../dump/win_dump.c:105:18: warning: variable 'ptr64' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../dump/win_dump.c:105:26: warning: variable 'ptr32' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../gdbstub/gdbstub.c:1191:39: warning: variable 'pid' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../gdbstub/gdbstub.c:1209:36: warning: variable 'tid' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/9pfs/9p.c:1911:13: warning: variable 'fidst' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/block/block.c:110:33: warning: variable 'bs' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/core/generic-loader.c:160:23: warning: variable 'entry' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/i386/intel_iommu.c:323:12: warning: variable 'entry' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/ide/ahci.c:968:60: warning: variable 'tbl_entry_size' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/microblaze/boot.c:107:42: warning: variable 'fdt_size' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/net/rtl8139.c:1801:20: warning: variable 'buf2' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/nios2/boot.c:118:44: warning: variable 'fdt_size' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/nvram/fw_cfg.c:1254:40: warning: variable 'data' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/ppc/mac_oldworld.c:148:26: warning: variable 'bios_addr' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/ppc/spapr.c:274:55: warning: variable 'pa_size' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/riscv/microchip_pfsoc.c:609:54: warning: variable
> 'firmware_load_addr' may be uninitialized when used here
> [-Wconditional-uninitialized]
> ../hw/s390x/css.c:553:9: warning: variable 'ret' may be uninitialized
> when used here [-Wconditional-uninitialized]
> ../hw/s390x/ipl.c:410:17: warning: variable 'devtype' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/s390x/s390-pci-inst.c:156:39: warning: variable 'res_code' may
> be uninitialized when used here [-Wconditional-uninitialized]
> ../hw/sd/sdhci.c:844:17: warning: variable 'res' may be uninitialized
> when used here [-Wconditional-uninitialized]
> ../hw/sparc64/sun4u_iommu.c:159:66: warning: variable 'offset' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/xtensa/mx_pic.c:260:27: warning: variable 'oldv' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../hw/xtensa/mx_pic.c:260:33: warning: variable 'newv' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../migration/block.c:989:17: warning: variable 'ret' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../migration/migration.c:2847:17: warning: variable 'file' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../migration/ram.c:2088:24: warning: variable 'dirty' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../migration/savevm.c:721:30: warning: variable 'se' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../monitor/misc.c:1908:20: warning: variable 'snapshots' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../nbd/client-connection.c:419:9: warning: variable 'wait_co' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../net/socket.c:389:24: warning: variable 'saddr' may be uninitialized
> when used here [-Wconditional-uninitialized]
> ../net/tap-bsd.c:70:9: warning: variable 'fd' may be uninitialized
> when used here [-Wconditional-uninitialized]
> ../plugins/loader.c:406:17: warning: variable 'ctx' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../qemu-nbd.c:1175:22: warning: variable 'client_thread' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../softmmu/vl.c:1006:13: warning: variable 'opts' may be uninitialized
> when used here [-Wconditional-uninitialized]
> ../target/arm/helper.c:3299:17: warning: variable 'target_el' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/arm/m_helper.c:1727:37: warning: variable 'xpsr' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/arm/m_helper.c:1814:36: warning: variable 'shi' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/arm/m_helper.c:1814:48: warning: variable 'slo' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/arm/m_helper.c:1820:40: warning: variable 'fpscr' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/arm/translate-a64.c:10572:51: warning: variable 'rmode' may
> be uninitialized when used here [-Wconditional-uninitialized]
> ../target/arm/translate-a64.c:13225:51: warning: variable 'rmode' may
> be uninitialized when used here [-Wconditional-uninitialized]
> ../target/arm/translate-a64.c:8519:34: warning: variable 'tcg_src_hi'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/arm/translate.c:1590:50: warning: variable 'tmp' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/cris/mmu.c:201:33: warning: variable 'lo' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/i386/ops_sse.h:2492:15: warning: variable 'r0' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/i386/ops_sse.h:2493:15: warning: variable 'r1' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/i386/ops_sse.h:2494:15: warning: variable 'r2' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/i386/ops_sse.h:2495:15: warning: variable 'r3' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/m68k/softfloat.c:825:44: warning: variable 'm1' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1251:10: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1269:10: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1493:10: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1516:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1517:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1518:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1519:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1520:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1521:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1522:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1523:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1524:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1525:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1526:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1527:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1680:10: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:1954:10: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:2039:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:2040:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:2061:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:2062:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:2063:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:2064:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:2065:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:2066:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:2945:10: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:2956:10: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:2987:10: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:3063:10: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:967:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:968:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/int_helper.c:969:1: warning: variable 'result' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/ppc/mmu-radix64.c:548:20: warning: variable 'pte' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/ioinst.c:364:52: warning: variable 'irb_len' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/mem_helper.c:2978:12: warning: variable 'cc' may
> be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:1023:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:132:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:156:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:278:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:301:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:439:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:471:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:551:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:592:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:635:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:659:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_fpu_helper.c:961:26: warning: variable 'vxc'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_helper.c:189:25: warning: variable 'tmp' may
> be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_helper.c:89:1: warning: variable 'tmp' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_helper.c:90:1: warning: variable 'tmp' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_helper.c:91:1: warning: variable 'tmp' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_int_helper.c:556:25: warning: variable 'tmp'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/s390x/tcg/vec_int_helper.c:606:25: warning: variable 'tmp'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../target/xtensa/translate.c:1074:51: warning: variable 'resource' may
> be uninitialized when used here [-Wconditional-uninitialized]
> ../target/xtensa/translate.c:1092:35: warning: variable 'temp' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/xtensa/translate.c:936:72: warning: variable 'rf' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../target/xtensa/xtensa-semi.c:297:17: warning: variable 'rc' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../tests/fp/berkeley-softfloat-3/source/s_shiftRightJam256M.c:117:10:
> warning: variable 'ptr' may be uninitialized when used here
> [-Wconditional-uninitialized]
> ../tests/fp/berkeley-testfloat-3/source/slowfloat.c:1015:13: warning:
> variable 'uiZ' may be uninitialized when used here
> [-Wconditional-uninitialized]
> ../tests/fp/berkeley-testfloat-3/source/slowfloat.c:742:13: warning:
> variable 'uiZ' may be uninitialized when used here
> [-Wconditional-uninitialized]
> ../tests/fp/berkeley-testfloat-3/source/slowfloat.c:878:13: warning:
> variable 'uiZ' may be uninitialized when used here
> [-Wconditional-uninitialized]
> ../tests/qtest/boot-sector.c:169:21: warning: variable 'signature' may
> be uninitialized when used here [-Wconditional-uninitialized]
> ../tests/qtest/prom-env-test.c:43:21: warning: variable 'signature'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../tests/unit/test-bdrv-drain.c:1022:21: warning: variable 'ret' may
> be uninitialized when used here [-Wconditional-uninitialized]
> ../tests/unit/test-block-iothread.c:772:14: warning: variable 'job'
> may be uninitialized when used here [-Wconditional-uninitialized]
> ../ui/vnc-enc-tight.c:416:1: warning: variable 'ci' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../ui/vnc-enc-tight.c:417:1: warning: variable 'ci' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../ui/vnc-enc-tight.c:418:1: warning: variable 'ci' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../util/iov.c:469:52: warning: variable 'mid_head' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../util/iov.c:471:36: warning: variable 'mid_tail' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../util/qemu-timer.c:198:12: warning: variable 'expire_time' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../util/qemu-timer.c:236:13: warning: variable 'expire_time' may be
> uninitialized when used here [-Wconditional-uninitialized]
> ../util/qemu-timer.c:476:9: warning: variable 'rearm' may be
> uninitialized when used here [-Wconditional-uninitialized]
>


Compiler warnings with maximum warning level (was: Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized)
Posted by Stefan Weil via 1 year, 4 months ago
Am 07.12.22 um 20:11 schrieb Stefan Weil:
>>>>>> On 12/7/22 14:24, Eric Auger wrote:
>>>>>>> Initialize r0-3 to avoid compilation errors when
>>>>>>> -Werror=maybe-uninitialized is used
>>>>>>>
>>>>>>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
>>>>>>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used
>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>    2495 |     d->Q(3) = r3;
>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used
>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>    2494 |     d->Q(2) = r2;
>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used
>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>    2493 |     d->Q(1) = r1;
>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used
>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>    2492 |     d->Q(0) = r0;
>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>>
>>>>>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>>>>>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
>>>>>>>
>>>>>>> ---
>>>>>>>
>>>>>>> Am I the only one getting this? Or anything wrong in my setup.
> 
> Hi Eric,
> 
> no, you are not the only one. I regularly build with higher warning 
> levels, for example with -Weverything on macOS, and get a much longer 
> list which includes the mentioned warnings (see below).

The latest QEMU code produces 6780505 compiler warnings and a build log 
file with 2.7 GB (!) with compiler option `-Weverything` on macOS.

Many warnings occur more than once, but there remain 193313 unique 
warnings for the QEMU code (see 
https://qemu.weilnetz.de/test/warnings-20221207.txt). Here is a list of 
all kinds of warnings sorted by frequency:

    1 -Wkeyword-macro
    1 -Wundeclared-selector
    1 -Wunreachable-code-loop-increment
    1 -Wunused-but-set-parameter
    2 -Wgnu-union-cast
    2 -Woverlength-strings
    3 -Walloca
    5 -Wflexible-array-extensions
    5 -Wstrict-selector-match
    5 -Wstring-conversion
    5 -Wtautological-value-range-compare
    6 -Wcstring-format-directive
    8 -Wstatic-in-inline
   13 -Wobjc-messaging-id
   13 -Wvla
   14 -Wobjc-interface-ivars
   16 -Wimplicit-float-conversion
   17 -Wformat-nonliteral
   24 -Wredundant-parens
   39 -Wfloat-equal
   44 -Wc++-compat
   47 -Wzero-length-array
   53 -Wdouble-promotion
   53 -Wvariadic-macros
   65 -Wpacked
   74 -Wcomma
   82 -Wunreachable-code-return
   90 -Wformat-pedantic
   90 -Wmissing-noreturn
   94 -Wgnu-flexible-array-initializer
  120 -Wcovered-switch-default
  132 -Wdirect-ivar-access
  136 -Wconditional-uninitialized
  144 -Wgnu-designator
  147 -Wdisabled-macro-expansion
  150 -Wgnu-conditional-omitted-operand
  161 -Wunreachable-code-break
  184 -Wcompound-token-split-by-space
  228 -Wfloat-conversion
  248 -Wunreachable-code
  348 -Wgnu-binary-literal
  443 -Wshadow
  534 -Wmissing-variable-declarations
  563 -Wshift-sign-overflow
  613 -Wembedded-directive
  620 -Wgnu-zero-variadic-macro-arguments
  742 -Wswitch-enum
  843 -Wdocumentation
  897 -Wgnu-case-range
1292 -Wassign-enum
1621 -Wgnu-empty-struct
1700 -Wextra-semi
1779 -Wpointer-arith
1847 -Wbad-function-cast
2176 -Wdocumentation-unknown-command
2221 -Wmissing-field-initializers
3101 -Wsign-compare
3238 -Wunused-macros
3559 -Wcast-align
4528 -Wcast-qual
7066 -Wgnu-statement-expression
7651 -Wnull-pointer-subtraction
7995 -Wimplicit-int-conversion
8854 -Wpadded
9737 -Wshorten-64-to-32
10596 -Wgnu-empty-initializer
13274 -Wlanguage-extension-token
13899 -Wunused-parameter
15642 -Wused-but-marked-unused
18669 -Wpedantic
44737 -Wsign-conversion

Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Stefan Hajnoczi 1 year, 4 months ago
On Wed, 7 Dec 2022 at 14:11, Stefan Weil <sw@weilnetz.de> wrote:
>
> Am 07.12.22 um 19:22 schrieb Eric Auger:
> >
> > On 12/7/22 17:55, Philippe Mathieu-Daudé wrote:
> >> On 7/12/22 15:33, Eric Auger wrote:
> >>> On 12/7/22 15:09, Stefan Hajnoczi wrote:
> >>>> On Wed, 7 Dec 2022 at 08:31, Eric Auger <eric.auger@redhat.com> wrote:
> >>>>> On 12/7/22 14:24, Eric Auger wrote:
> >>>>>> Initialize r0-3 to avoid compilation errors when
> >>>>>> -Werror=maybe-uninitialized is used
> >>>>>>
> >>>>>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
> >>>>>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used
> >>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
> >>>>>>    2495 |     d->Q(3) = r3;
> >>>>>>         |     ~~~~~~~~^~~~
> >>>>>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used
> >>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
> >>>>>>    2494 |     d->Q(2) = r2;
> >>>>>>         |     ~~~~~~~~^~~~
> >>>>>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used
> >>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
> >>>>>>    2493 |     d->Q(1) = r1;
> >>>>>>         |     ~~~~~~~~^~~~
> >>>>>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used
> >>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
> >>>>>>    2492 |     d->Q(0) = r0;
> >>>>>>         |     ~~~~~~~~^~~~
> >>>>>>
> >>>>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> >>>>>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
> >>>>>>
> >>>>>> ---
> >>>>>>
> >>>>>> Am I the only one getting this? Or anything wrong in my setup.
>
> Hi Eric,
>
> no, you are not the only one. I regularly build with higher warning
> levels, for example with -Weverything on macOS, and get a much longer
> list which includes the mentioned warnings (see below).
>
> The warnings for ops_sse.h are false positives, so I think no fix is
> needed for 7.2. The compiler is not clever enough to see that the switch
> statements handle all possible cases. It should be sufficient to replace
> `case 3` by `default` to help the compiler and fix the warning. Your fix
> might produce new compiler warnings because setting the variables to 0
> has no effect.

Eric: do you want to try the switch "default" approach for 8.0?

Thanks,
Stefan
Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Eric Auger 1 year, 4 months ago
Hi Stefan,

On 12/7/22 20:59, Stefan Hajnoczi wrote:
> On Wed, 7 Dec 2022 at 14:11, Stefan Weil <sw@weilnetz.de> wrote:
>> Am 07.12.22 um 19:22 schrieb Eric Auger:
>>> On 12/7/22 17:55, Philippe Mathieu-Daudé wrote:
>>>> On 7/12/22 15:33, Eric Auger wrote:
>>>>> On 12/7/22 15:09, Stefan Hajnoczi wrote:
>>>>>> On Wed, 7 Dec 2022 at 08:31, Eric Auger <eric.auger@redhat.com> wrote:
>>>>>>> On 12/7/22 14:24, Eric Auger wrote:
>>>>>>>> Initialize r0-3 to avoid compilation errors when
>>>>>>>> -Werror=maybe-uninitialized is used
>>>>>>>>
>>>>>>>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
>>>>>>>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used
>>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>>    2495 |     d->Q(3) = r3;
>>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used
>>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>>    2494 |     d->Q(2) = r2;
>>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used
>>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>>    2493 |     d->Q(1) = r1;
>>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used
>>>>>>>> uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>>>>    2492 |     d->Q(0) = r0;
>>>>>>>>         |     ~~~~~~~~^~~~
>>>>>>>>
>>>>>>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>>>>>>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
>>>>>>>>
>>>>>>>> ---
>>>>>>>>
>>>>>>>> Am I the only one getting this? Or anything wrong in my setup.
>> Hi Eric,
>>
>> no, you are not the only one. I regularly build with higher warning
>> levels, for example with -Weverything on macOS, and get a much longer
>> list which includes the mentioned warnings (see below).
>>
>> The warnings for ops_sse.h are false positives, so I think no fix is
>> needed for 7.2. The compiler is not clever enough to see that the switch
>> statements handle all possible cases. It should be sufficient to replace
>> `case 3` by `default` to help the compiler and fix the warning. Your fix
>> might produce new compiler warnings because setting the variables to 0
>> has no effect.
> Eric: do you want to try the switch "default" approach for 8.0?

Yes sure!

Eric
>
> Thanks,
> Stefan
>


Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Stefan Hajnoczi 1 year, 4 months ago
On Wed, 7 Dec 2022 at 09:34, Eric Auger <eric.auger@redhat.com> wrote:
>
> Hi Stefan,
>
> On 12/7/22 15:09, Stefan Hajnoczi wrote:
> > On Wed, 7 Dec 2022 at 08:31, Eric Auger <eric.auger@redhat.com> wrote:
> >> On 12/7/22 14:24, Eric Auger wrote:
> >>> Initialize r0-3 to avoid compilation errors when
> >>> -Werror=maybe-uninitialized is used
> >>>
> >>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
> >>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >>>  2495 |     d->Q(3) = r3;
> >>>       |     ~~~~~~~~^~~~
> >>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >>>  2494 |     d->Q(2) = r2;
> >>>       |     ~~~~~~~~^~~~
> >>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >>>  2493 |     d->Q(1) = r1;
> >>>       |     ~~~~~~~~^~~~
> >>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >>>  2492 |     d->Q(0) = r0;
> >>>       |     ~~~~~~~~^~~~
> >>>
> >>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> >>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
> >>>
> >>> ---
> >>>
> >>> Am I the only one getting this? Or anything wrong in my setup.
> >> With Stefan's correct address. Forgive me for the noise.
> > When is -Wmaybe-uninitialized used? QEMU's build system doesn't set
> > it. Unless it's automatically set by meson this must be a manual
> > --extra-cflags= option you set.
>
> I am using this configure cmd line:
>
> ./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib/qemu
> --target-list=x86_64-softmmu --docdir=/usr/share/doc/qemu --enable-kvm
> --extra-cflags=-O --enable-trace-backends=log --python=/usr/bin/python3
> --extra-cflags=-Wall --extra-cflags=-Wundef
> --extra-cflags=-Wwrite-strings --extra-cflags=-Wmissing-prototypes
> --extra-cflags=-fno-strict-aliasing --extra-cflags=-fno-common
> --extra-cflags=-Werror=type-limits
> >
> > If you added it manually then let's fix this in 8.0 since it's not
> > tested/supported and very few people will see this issue.

Did you create the ./configure command-line manually? Do you think
other people will hit this?

Stefan
Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Eric Auger 1 year, 4 months ago
Hi Stefan,

On 12/7/22 16:55, Stefan Hajnoczi wrote:
> On Wed, 7 Dec 2022 at 09:34, Eric Auger <eric.auger@redhat.com> wrote:
>> Hi Stefan,
>>
>> On 12/7/22 15:09, Stefan Hajnoczi wrote:
>>> On Wed, 7 Dec 2022 at 08:31, Eric Auger <eric.auger@redhat.com> wrote:
>>>> On 12/7/22 14:24, Eric Auger wrote:
>>>>> Initialize r0-3 to avoid compilation errors when
>>>>> -Werror=maybe-uninitialized is used
>>>>>
>>>>> ../target/i386/ops_sse.h: In function ‘helper_vpermdq_ymm’:
>>>>> ../target/i386/ops_sse.h:2495:13: error: ‘r3’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>  2495 |     d->Q(3) = r3;
>>>>>       |     ~~~~~~~~^~~~
>>>>> ../target/i386/ops_sse.h:2494:13: error: ‘r2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>  2494 |     d->Q(2) = r2;
>>>>>       |     ~~~~~~~~^~~~
>>>>> ../target/i386/ops_sse.h:2493:13: error: ‘r1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>  2493 |     d->Q(1) = r1;
>>>>>       |     ~~~~~~~~^~~~
>>>>> ../target/i386/ops_sse.h:2492:13: error: ‘r0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>>>>  2492 |     d->Q(0) = r0;
>>>>>       |     ~~~~~~~~^~~~
>>>>>
>>>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>>>> Fixes: 790684776861 ("target/i386: reimplement 0x0f 0x3a, add AVX")
>>>>>
>>>>> ---
>>>>>
>>>>> Am I the only one getting this? Or anything wrong in my setup.
>>>> With Stefan's correct address. Forgive me for the noise.
>>> When is -Wmaybe-uninitialized used? QEMU's build system doesn't set
>>> it. Unless it's automatically set by meson this must be a manual
>>> --extra-cflags= option you set.
>> I am using this configure cmd line:
>>
>> ./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib/qemu
>> --target-list=x86_64-softmmu --docdir=/usr/share/doc/qemu --enable-kvm
>> --extra-cflags=-O --enable-trace-backends=log --python=/usr/bin/python3
>> --extra-cflags=-Wall --extra-cflags=-Wundef
>> --extra-cflags=-Wwrite-strings --extra-cflags=-Wmissing-prototypes
>> --extra-cflags=-fno-strict-aliasing --extra-cflags=-fno-common
>> --extra-cflags=-Werror=type-limits
>>> If you added it manually then let's fix this in 8.0 since it's not
>>> tested/supported and very few people will see this issue.
> Did you create the ./configure command-line manually? Do you think
> other people will hit this?
no I did not. I just tried to install a fresh qemu repo and just ran the
above configure command. You should be able to reproduce I think.

I am actually surprised nobody hit that already.

Thanks

Eric
>
> Stefan
>


Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Richard Henderson 1 year, 4 months ago
On 12/7/22 10:08, Eric Auger wrote:
> On 12/7/22 16:55, Stefan Hajnoczi wrote:
>>> I am using this configure cmd line:
>>>
>>> ./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib/qemu
>>> --target-list=x86_64-softmmu --docdir=/usr/share/doc/qemu --enable-kvm
>>> --extra-cflags=-O --enable-trace-backends=log --python=/usr/bin/python3
>>> --extra-cflags=-Wall --extra-cflags=-Wundef
>>> --extra-cflags=-Wwrite-strings --extra-cflags=-Wmissing-prototypes
>>> --extra-cflags=-fno-strict-aliasing --extra-cflags=-fno-common
>>> --extra-cflags=-Werror=type-limits
>>>> If you added it manually then let's fix this in 8.0 since it's not
>>>> tested/supported and very few people will see this issue.
>> Did you create the ./configure command-line manually? Do you think
>> other people will hit this?
> no I did not. I just tried to install a fresh qemu repo and just ran the
> above configure command.

Stefan's question is where did you get this configure command?

If it came from an rpm script or suchlike, we might take more notice than if this is just 
you adding --extra-cflags for your own testing.


> I am actually surprised nobody hit that already.

Adding -Wall is not standard, nor all the other -W that you are adding.  I think you 
should not be surprised that you run into problems.

While you can make a case for auditing the code base and adding these to the default set 
of warning flags, that's a job for the next development cycle.


r~
Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Eric Auger 1 year, 4 months ago
Hi,

On 12/7/22 19:23, Richard Henderson wrote:
> On 12/7/22 10:08, Eric Auger wrote:
>> On 12/7/22 16:55, Stefan Hajnoczi wrote:
>>>> I am using this configure cmd line:
>>>>
>>>> ./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib/qemu
>>>> --target-list=x86_64-softmmu --docdir=/usr/share/doc/qemu --enable-kvm
>>>> --extra-cflags=-O --enable-trace-backends=log
>>>> --python=/usr/bin/python3
>>>> --extra-cflags=-Wall --extra-cflags=-Wundef
>>>> --extra-cflags=-Wwrite-strings --extra-cflags=-Wmissing-prototypes
>>>> --extra-cflags=-fno-strict-aliasing --extra-cflags=-fno-common
>>>> --extra-cflags=-Werror=type-limits
>>>>> If you added it manually then let's fix this in 8.0 since it's not
>>>>> tested/supported and very few people will see this issue.
>>> Did you create the ./configure command-line manually? Do you think
>>> other people will hit this?
>> no I did not. I just tried to install a fresh qemu repo and just ran the
>> above configure command.
>
> Stefan's question is where did you get this configure command?
this is the native unmodified configure from
https://git.qemu.org/git/qemu.git/.
>
> If it came from an rpm script or suchlike, we might take more notice
> than if this is just you adding --extra-cflags for your own testing.
>
>
>> I am actually surprised nobody hit that already.
>
> Adding -Wall is not standard, nor all the other -W that you are
> adding.  I think you should not be surprised that you run into problems.
OK that's a useful indication. I used to have this configure cmd line
for a while and have not paid much attention to it until now, I
acknowledge. This was useful to catch compilation errors at some point I
guess.
>
> While you can make a case for auditing the code base and adding these
> to the default set of warning flags, that's a job for the next
> development cycle.

Let me clarify, I am not insisting for that fix to land in 7.2 all the
more so it is pretty late. I just wanted to report the compilation issue
and since I use the std qemu pieces with a pretty standard tool chain I
thought somebody else would be likely to hit the same problem.

Thanks

Eric
>
>
> r~
>


Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Peter Maydell 1 year, 4 months ago
On Wed, 7 Dec 2022 at 18:44, Eric Auger <eric.auger@redhat.com> wrote:
> On 12/7/22 19:23, Richard Henderson wrote:
> > Adding -Wall is not standard, nor all the other -W that you are
> > adding.  I think you should not be surprised that you run into problems.
> OK that's a useful indication. I used to have this configure cmd line
> for a while and have not paid much attention to it until now, I
> acknowledge. This was useful to catch compilation errors at some point I
> guess.
> >
> > While you can make a case for auditing the code base and adding these
> > to the default set of warning flags, that's a job for the next
> > development cycle.
>
> Let me clarify, I am not insisting for that fix to land in 7.2 all the
> more so it is pretty late. I just wanted to report the compilation issue
> and since I use the std qemu pieces with a pretty standard tool chain I
> thought somebody else would be likely to hit the same problem.

As Richard says, we don't expect people to randomly add extra
warning flags, and anybody who does should expect to see extra
warnings (and that they need to --disable-werror if they don't want
those extra warnings to turn into errors).

We specifically disable some warnings, there are some not-on-by-default
warnings that we know we have work to do if we want to eliminate them
(eg -Wvla) and there's probably a few where we conceptually disagree
with a warning flag or don't find it useful for QEMU (like
-Wgnu-statement-expression -- we deliberately use GNU statement
expressions so warning about them isn't useful to us).

Sorting through which of the currently non-enabled warning flags
are worth trying to fix existing warnings and enable by default
is a pretty big task (not dissimilar to sorting through Coverity
issue reports -- maybe some of the things you fix are real bugs
but there's a lot of false-positives to wade through to get there).

maybe-uninitialized warnings are particularly awkward because whether
you get them depends a lot on the version of the compiler and how
smart its data analysis is.

thanks
-- PMM
Re: [PATCH for 7.2?] target/i386: Remove compilation errors when -Werror=maybe-uninitialized
Posted by Eric Auger 1 year, 4 months ago
Hi Peter,

On 12/7/22 21:28, Peter Maydell wrote:
> On Wed, 7 Dec 2022 at 18:44, Eric Auger <eric.auger@redhat.com> wrote:
>> On 12/7/22 19:23, Richard Henderson wrote:
>>> Adding -Wall is not standard, nor all the other -W that you are
>>> adding.  I think you should not be surprised that you run into problems.
>> OK that's a useful indication. I used to have this configure cmd line
>> for a while and have not paid much attention to it until now, I
>> acknowledge. This was useful to catch compilation errors at some point I
>> guess.
>>> While you can make a case for auditing the code base and adding these
>>> to the default set of warning flags, that's a job for the next
>>> development cycle.
>> Let me clarify, I am not insisting for that fix to land in 7.2 all the
>> more so it is pretty late. I just wanted to report the compilation issue
>> and since I use the std qemu pieces with a pretty standard tool chain I
>> thought somebody else would be likely to hit the same problem.
> As Richard says, we don't expect people to randomly add extra
> warning flags, and anybody who does should expect to see extra
> warnings (and that they need to --disable-werror if they don't want
> those extra warnings to turn into errors).
>
> We specifically disable some warnings, there are some not-on-by-default
> warnings that we know we have work to do if we want to eliminate them
> (eg -Wvla) and there's probably a few where we conceptually disagree
> with a warning flag or don't find it useful for QEMU (like
> -Wgnu-statement-expression -- we deliberately use GNU statement
> expressions so warning about them isn't useful to us).
>
> Sorting through which of the currently non-enabled warning flags
> are worth trying to fix existing warnings and enable by default
> is a pretty big task (not dissimilar to sorting through Coverity
> issue reports -- maybe some of the things you fix are real bugs
> but there's a lot of false-positives to wade through to get there).
>
> maybe-uninitialized warnings are particularly awkward because whether
> you get them depends a lot on the version of the compiler and how
> smart its data analysis is.

OK. I don't exactly remember how I came to this configure cmd line.
Maybe in the old times bots were complaining about such kind of warnings
or some of the extra warning flags were used downstream. I simply
thought we had a stricter policy with regards to those and I have been
using this configure command for a long time, without trouble, until
recently, hence that belief.

Thanks

Eric
>
> thanks
> -- PMM
>