linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: kvm: move declaration at the beginning of main()
@ 2023-01-22  9:08 Paolo Bonzini
  2023-01-23 16:27 ` David Matlack
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2023-01-22  9:08 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: Yu Zhang, Sean Christopherson

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>
---
 tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
index dae510c263b4..13c75dc18c10 100644
--- a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
+++ b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
@@ -434,6 +434,7 @@ static void *juggle_shinfo_state(void *arg)
 int main(int argc, char *argv[])
 {
 	struct timespec min_ts, max_ts, vm_ts;
+	struct kvm_xen_hvm_attr evt_reset;
 	struct kvm_vm *vm;
 	pthread_t thread;
 	bool verbose;
@@ -962,10 +963,8 @@ int main(int argc, char *argv[])
 	}
 
  done:
-	struct kvm_xen_hvm_attr evt_reset = {
-		.type = KVM_XEN_ATTR_TYPE_EVTCHN,
-		.u.evtchn.flags = KVM_XEN_EVTCHN_RESET,
-	};
+	evt_reset.type = KVM_XEN_ATTR_TYPE_EVTCHN;
+	evt_reset.u.evtchn.flags = KVM_XEN_EVTCHN_RESET;
 	vm_ioctl(vm, KVM_XEN_HVM_SET_ATTR, &evt_reset);
 
 	alarm(0);
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] selftests: kvm: move declaration at the beginning of main()
  2023-01-22  9:08 [PATCH] selftests: kvm: move declaration at the beginning of main() Paolo Bonzini
@ 2023-01-23 16:27 ` David Matlack
  0 siblings, 0 replies; 2+ messages in thread
From: David Matlack @ 2023-01-23 16:27 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, kvm, Yu Zhang, Sean Christopherson

On Sun, Jan 22, 2023 at 1:09 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> 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>

Thanks, I had a similar patch queued up to send out today :)

Can you add clang to your workflow for queueing patches? It's not the
first time a selftest patch that does not build with clang has snuck
into kvm/queue or even an rc [1].

[1] git log --oneline --grep Fixes: --grep clang --all-match
tools/testing/selftests/kvm

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-23 16:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-22  9:08 [PATCH] selftests: kvm: move declaration at the beginning of main() Paolo Bonzini
2023-01-23 16:27 ` David Matlack

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).