From nobody Mon Feb 9 05:42:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690987147036891.6019406076412; Wed, 2 Aug 2023 07:39:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.574973.900637 (Exim 4.92) (envelope-from ) id 1qRCzo-0006px-NU; Wed, 02 Aug 2023 14:38:40 +0000 Received: by outflank-mailman (output) from mailman id 574973.900637; Wed, 02 Aug 2023 14:38:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRCzo-0006ms-Hy; Wed, 02 Aug 2023 14:38:40 +0000 Received: by outflank-mailman (input) for mailman id 574973; Wed, 02 Aug 2023 14:38:39 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRCzn-0006bO-Pv for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 14:38:39 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 44f44a64-3142-11ee-b260-6b7b168915f2; Wed, 02 Aug 2023 16:38:39 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id D50094EE0741; Wed, 2 Aug 2023 16:38:37 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 44f44a64-3142-11ee-b260-6b7b168915f2 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, Nicola Vetrini , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [XEN PATCH 02/11] x86: move declarations to address MISRA C:2012 Rule 2.1 Date: Wed, 2 Aug 2023 16:38:08 +0200 Message-Id: <204bf3ffcdda04d6d6cf072c42b78720e1e85b4d.1690985045.git.nicola.vetrini@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1690989360675100001 Content-Type: text/plain; charset="utf-8" Variable declarations between a switch statement guard and before any case label are unreachable code, and hence violate Rule 2.1: "A project shall not contain unreachable code". Therefore the declarations are moved in the smallest enclosing scope, near other variable definitions. Signed-off-by: Nicola Vetrini --- xen/arch/x86/cpuid.c | 3 +-- xen/arch/x86/domain.c | 23 +++++++++++------------ xen/arch/x86/irq.c | 3 +-- xen/arch/x86/msr.c | 3 +-- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index 455a09b2dd..90e1370e90 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -37,6 +37,7 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, { const struct domain *d =3D v->domain; const struct cpu_policy *p =3D d->arch.cpu_policy; + const struct cpu_user_regs *regs; =20 *res =3D EMPTY_LEAF; =20 @@ -136,8 +137,6 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, */ switch ( leaf ) { - const struct cpu_user_regs *regs; - case 0x1: /* TODO: Rework topology logic. */ res->b &=3D 0x00ffffffu; diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 5f66c2ae33..015f7b14ab 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -2268,6 +2268,17 @@ int domain_relinquish_resources(struct domain *d) { int ret; struct vcpu *v; + enum { + PROG_iommu_pagetables =3D 1, + PROG_shared, + PROG_paging, + PROG_vcpu_pagetables, + PROG_xen, + PROG_l4, + PROG_l3, + PROG_l2, + PROG_done, + }; =20 BUG_ON(!cpumask_empty(d->dirty_cpumask)); =20 @@ -2291,18 +2302,6 @@ int domain_relinquish_resources(struct domain *d) #define PROGRESS(x) \ d->arch.rel_priv =3D PROG_ ## x; /* Fallthrough */ case PROG_ ## x =20 - enum { - PROG_iommu_pagetables =3D 1, - PROG_shared, - PROG_paging, - PROG_vcpu_pagetables, - PROG_xen, - PROG_l4, - PROG_l3, - PROG_l2, - PROG_done, - }; - case 0: ret =3D pci_release_devices(d); if ( ret ) diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index 6abfd81621..4fd0cc163d 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -1135,6 +1135,7 @@ static void cf_check irq_guest_eoi_timer_fn(void *dat= a) struct irq_desc *desc =3D data; unsigned int i, irq =3D desc - irq_desc; irq_guest_action_t *action; + cpumask_t *cpu_eoi_map; =20 spin_lock_irq(&desc->lock); =20 @@ -1169,8 +1170,6 @@ static void cf_check irq_guest_eoi_timer_fn(void *dat= a) =20 switch ( action->ack_type ) { - cpumask_t *cpu_eoi_map; - case ACKTYPE_UNMASK: if ( desc->handler->end ) desc->handler->end(desc, 0); diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index ecf126566d..0e61e0fe4e 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -335,11 +335,10 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_= t val) const struct cpu_policy *cp =3D d->arch.cpu_policy; struct vcpu_msrs *msrs =3D v->arch.msrs; int ret =3D X86EMUL_OKAY; + uint64_t rsvd; =20 switch ( msr ) { - uint64_t rsvd; - /* Read-only */ case MSR_IA32_PLATFORM_ID: case MSR_CORE_CAPABILITIES: --=20 2.34.1