selftests: kvm: move declaration at the beginning of main()
authorPaolo Bonzini <pbonzini@redhat.com>
Sun, 22 Jan 2023 09:04:50 +0000 (04:04 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Feb 2023 10:25:40 +0000 (11:25 +0100)
commit05197a0916f5f2adab282e4868f21113ccaaf837
tree4f6326dcd077a29565a2062675427af13d517ece
parent0e2dba8c0ebeaf2e32b71356ea3df8d578057935
selftests: kvm: move declaration at the beginning of main()

[ Upstream commit 50aa870ba2f7735f556e52d15f61cd0f359c4c0b ]

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: a79b53aaaab5 ("KVM: x86: fix deadlock for KVM_XEN_EVTCHN_RESET", 2022-12-28)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c