From patchwork Wed Aug 2 14:38:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13338252 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 30473C001E0 for ; Wed, 2 Aug 2023 14:38:57 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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; set_xen_guest_handle(nat.hnd, COMPAT_ARG_XLAT_VIRT_BASE); split = 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, + }; BUG_ON(!d->is_dying); @@ -435,14 +442,6 @@ static int domain_teardown(struct domain *d) case PROG_vcpu_ ## x: \ v = d->teardown.vcpu - enum { - PROG_none, - PROG_gnttab_mappings, - PROG_vcpu_teardown, - PROG_arch_teardown, - PROG_done, - }; - case PROG_none: BUILD_BUG_ON(PROG_none != 0);