Skip to content

Commit 50aa870

Browse files
committed
selftests: kvm: move declaration at the beginning of main()
Placing a declaration of evt_reset is pedantically invalid according to the C standard. While GCC does not really care and only warns with -Wpedantic, clang ignores the declaration altogether with an error: x86_64/xen_shinfo_test.c:965:2: error: expected expression struct kvm_xen_hvm_attr evt_reset = { ^ x86_64/xen_shinfo_test.c:969:38: error: use of undeclared identifier evt_reset vm_ioctl(vm, KVM_XEN_HVM_SET_ATTR, &evt_reset); ^ Reported-by: Yu Zhang <yu.c.zhang@linux.intel.com> Reported-by: Sean Christopherson <seanjc@google.com> Fixes: a79b53a ("KVM: x86: fix deadlock for KVM_XEN_EVTCHN_RESET", 2022-12-28) Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent d732cbf commit 50aa870

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ static void *juggle_shinfo_state(void *arg)
434434
int main(int argc, char *argv[])
435435
{
436436
struct timespec min_ts, max_ts, vm_ts;
437+
struct kvm_xen_hvm_attr evt_reset;
437438
struct kvm_vm *vm;
438439
pthread_t thread;
439440
bool verbose;
@@ -962,10 +963,8 @@ int main(int argc, char *argv[])
962963
}
963964

964965
done:
965-
struct kvm_xen_hvm_attr evt_reset = {
966-
.type = KVM_XEN_ATTR_TYPE_EVTCHN,
967-
.u.evtchn.flags = KVM_XEN_EVTCHN_RESET,
968-
};
966+
evt_reset.type = KVM_XEN_ATTR_TYPE_EVTCHN;
967+
evt_reset.u.evtchn.flags = KVM_XEN_EVTCHN_RESET;
969968
vm_ioctl(vm, KVM_XEN_HVM_SET_ATTR, &evt_reset);
970969

971970
alarm(0);

0 commit comments

Comments
 (0)