From nobody Mon Feb 9 10:51:43 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 1690987148289340.676860512419; Wed, 2 Aug 2023 07:39:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.574979.900708 (Exim 4.92) (envelope-from ) id 1qRCzv-0000Fe-UB; Wed, 02 Aug 2023 14:38:47 +0000 Received: by outflank-mailman (output) from mailman id 574979.900708; Wed, 02 Aug 2023 14:38:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRCzv-0000Dx-Fv; Wed, 02 Aug 2023 14:38:47 +0000 Received: by outflank-mailman (input) for mailman id 574979; Wed, 02 Aug 2023 14:38:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRCzt-0007ap-7L for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 14:38:45 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 47b43c9a-3142-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 16:38:43 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id C89704EE0740; Wed, 2 Aug 2023 16:38:42 +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: 47b43c9a-3142-11ee-8613-37d641c3527e 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 , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN PATCH 08/11] xen: move declarations to address MISRA C:2012 Rule 2.1 Date: Wed, 2 Aug 2023 16:38:14 +0200 Message-Id: <055dce166662183c68fb488fa7f7722a3a5fcd98.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: 1690989387818100001 Content-Type: text/plain; charset="utf-8" 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 variable declarations are moved in the smallest enclosing scope, near other variable definitions. Signed-off-by: Nicola Vetrini --- xen/common/compat/memory.c | 3 +-- xen/common/domain.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/xen/common/compat/memory.c b/xen/common/compat/memory.c index 8ca63ceda6..d4c4204119 100644 --- a/xen/common/compat/memory.c +++ b/xen/common/compat/memory.c @@ -85,13 +85,12 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) struct compat_mem_access_op mao; struct compat_mem_acquire_resource mar; } cmp; + xen_pfn_t *space; =20 set_xen_guest_handle(nat.hnd, COMPAT_ARG_XLAT_VIRT_BASE); split =3D 0; switch ( op ) { - xen_pfn_t *space; - case XENMEM_increase_reservation: case XENMEM_decrease_reservation: case XENMEM_populate_physmap: diff --git a/xen/common/domain.c b/xen/common/domain.c index 304aa04fa6..e3aeaf059d 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -401,6 +401,13 @@ static int domain_teardown(struct domain *d) { struct vcpu *v; int rc; + enum { + PROG_none, + PROG_gnttab_mappings, + PROG_vcpu_teardown, + PROG_arch_teardown, + PROG_done, + }; =20 BUG_ON(!d->is_dying); =20 @@ -435,14 +442,6 @@ static int domain_teardown(struct domain *d) case PROG_vcpu_ ## x: \ v =3D d->teardown.vcpu =20 - enum { - PROG_none, - PROG_gnttab_mappings, - PROG_vcpu_teardown, - PROG_arch_teardown, - PROG_done, - }; - case PROG_none: BUILD_BUG_ON(PROG_none !=3D 0); =20 --=20 2.34.1