@@ -37,7 +37,7 @@ int kvm_cpu__register_kvm_arm_target(struct kvm_arm_target *target)
struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
{
- struct kvm_arm_target *target;
+ struct kvm_arm_target *target = NULL;
struct kvm_cpu *vcpu;
int coalesced_offset, mmap_size, err = -1;
unsigned int i;
@@ -81,7 +81,6 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
err = ioctl(kvm->vm_fd, KVM_ARM_PREFERRED_TARGET, &preferred_init);
if (!err) {
/* Match preferred target CPU type. */
- target = NULL;
for (i = 0; i < ARRAY_SIZE(kvm_arm_targets); ++i) {
if (!kvm_arm_targets[i])
continue;
GCC 13.1 complains about uninitialized value: arm/kvm-cpu.c: In function 'kvm_cpu__arch_init': arm/kvm-cpu.c:119:41: error: 'target' may be used uninitialized [-Werror=maybe-uninitialized] 119 | vcpu->cpu_compatible = target->compatible; | ~~~~~~^~~~~~~~~~~~ arm/kvm-cpu.c:40:32: note: 'target' was declared here 40 | struct kvm_arm_target *target; | ^~~~~~ This can't happen in practice (we call die() when no target is found), but initialize the target variable earlier to make GCC happy. Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> --- arm/kvm-cpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)