[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 3/9] kvm: workaround build break on gcc-7.1.1 / fedor
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 3/9] kvm: workaround build break on gcc-7.1.1 / fedora26 |
Date: |
Tue, 8 Aug 2017 17:29:35 +0200 |
From: Greg Kurz <address@hidden>
Building QEMU on fedora26 with the latest gcc package fails:
CC ppc64-softmmu/target/ppc/kvm.o
In file included from include/sysemu/hw_accel.h:16:0,
from target/ppc/kvm.c:31:
target/ppc/kvm.c: In function ‘kvmppc_booke_watchdog_enable’:
include/sysemu/kvm.h:449:35: error: ‘args_tmp[i]’ may be used uninitialized
in this function [-Werror=maybe-uninitialized]
cap.args[i] = args_tmp[i]; \
^
target/ppc/kvm.c: In function ‘kvmppc_set_papr’:
include/sysemu/kvm.h:449:35: error: ‘args_tmp[i]’ may be used uninitialized
in this function [-Werror=maybe-uninitialized]
cc1: all warnings being treated as errors
$ rpm -q gcc
gcc-7.1.1-3.fc26.ppc64le
The compiler should obviously optimize this code away when no extra
agument is passed to kvm_vm_enable_cap() and kvm_vcpu_enable_cap(),
but it doesn't. This bug should be fixed one day in gcc, but we can
also change our code pattern so that we don't hit the issue anymore.
We workaround this, by using memcpy() instead of open-coding the copy.
Signed-off-by: Greg Kurz <address@hidden>
Message-Id: <address@hidden>
Acked-by: Cornelia Huck <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/sysemu/kvm.h | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 91fc07ee9a..3a458f50e9 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -428,11 +428,8 @@ int kvm_vm_check_extension(KVMState *s, unsigned int
extension);
.flags = cap_flags, \
}; \
uint64_t args_tmp[] = { __VA_ARGS__ }; \
- int i; \
- for (i = 0; i < (int)ARRAY_SIZE(args_tmp) && \
- i < ARRAY_SIZE(cap.args); i++) { \
- cap.args[i] = args_tmp[i]; \
- } \
+ size_t n = MIN(ARRAY_SIZE(args_tmp), ARRAY_SIZE(cap.args)); \
+ memcpy(cap.args, args_tmp, n * sizeof(cap.args[0])); \
kvm_vm_ioctl(s, KVM_ENABLE_CAP, &cap); \
})
@@ -443,11 +440,8 @@ int kvm_vm_check_extension(KVMState *s, unsigned int
extension);
.flags = cap_flags, \
}; \
uint64_t args_tmp[] = { __VA_ARGS__ }; \
- int i; \
- for (i = 0; i < (int)ARRAY_SIZE(args_tmp) && \
- i < ARRAY_SIZE(cap.args); i++) { \
- cap.args[i] = args_tmp[i]; \
- } \
+ size_t n = MIN(ARRAY_SIZE(args_tmp), ARRAY_SIZE(cap.args)); \
+ memcpy(cap.args, args_tmp, n * sizeof(cap.args[0])); \
kvm_vcpu_ioctl(cpu, KVM_ENABLE_CAP, &cap); \
})
--
2.13.3
- [Qemu-devel] [PULL 0/9] Misc patches for 2017-08-08, Paolo Bonzini, 2017/08/08
- [Qemu-devel] [PULL 1/9] rcu: completely disable pthread_atfork callbacks as soon as possible, Paolo Bonzini, 2017/08/08
- [Qemu-devel] [PULL 5/9] target/i386: set rip_offset for some SSE4.1 instructions, Paolo Bonzini, 2017/08/08
- [Qemu-devel] [PULL 6/9] qemu-img: Sort sub-command names in --help, Paolo Bonzini, 2017/08/08
- [Qemu-devel] [PULL 3/9] kvm: workaround build break on gcc-7.1.1 / fedora26,
Paolo Bonzini <=
- [Qemu-devel] [PULL 4/9] scsi: clarify sense codes for LUN0 emulation, Paolo Bonzini, 2017/08/08
- [Qemu-devel] [PULL 2/9] Revert "rcu: do not create thread in pthread_atfork callback", Paolo Bonzini, 2017/08/08
- [Qemu-devel] [PULL 7/9] qemu-io: Give more --version information, Paolo Bonzini, 2017/08/08
- [Qemu-devel] [PULL 8/9] qga: Give more --version information, Paolo Bonzini, 2017/08/08
- [Qemu-devel] [PULL 9/9] maint: Include bug-reporting info in --help output, Paolo Bonzini, 2017/08/08
- Re: [Qemu-devel] [PULL 0/9] Misc patches for 2017-08-08, Peter Maydell, 2017/08/08