Message ID | 20220330210443.597500-1-danielhb413@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | ppc: valgrind "uninitialized values" fixes | expand |
On 30/3/22 23:04, Daniel Henrique Barboza wrote: > Hi, > > These are a handful of trivial fixes to make Valgrind happier when > profiling the boot of a pSeries guest. All the patches are handling a > similar case where we have something similar to this: > > --- > uint64_t val; > > (...) > > kvm_vcpu_ioctl(...., &val); Which is a false positive. > --- > > Valgrind does not consider that 'val' was initialized and then it keeps > complaining about every future use of 'val', or anything that got > assigned as 'val', as being an uninitialized value/data. The fix is > simple and without any side effects:: just initialize 'val'. I gave a try to some definition but the result is rather ugly =) -- >8 -- diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index d9359859d4..85429930fb 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -194,4 +194,10 @@ extern void QEMU_NORETURN QEMU_ERROR("code path is reachable") #define QEMU_DISABLE_CFI #endif +#ifdef QEMU_STATIC_ANALYSIS +#define QEMU_UNNECESSARY_INIT(values...) = values +#else +#define QEMU_UNNECESSARY_INIT(values...) +#endif + #endif /* COMPILER_H */ diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index dc93b99189..97aec29694 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -546,7 +546,7 @@ static void kvm_get_one_spr(CPUState *cs, uint64_t id, int spr) union { uint32_t u32; uint64_t u64; - } val; + } val QEMU_UNNECESSARY_INIT({ }); struct kvm_one_reg reg = { .id = id, .addr = (uintptr_t) &val, --- Being able to use valgrind is more valuable that these unnecessary init, so: Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>