From patchwork Wed Aug 2 14:38:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13338244 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 40D7AC04FE0 for ; Wed, 2 Aug 2023 14:38:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.574978.900680 (Exim 4.92) (envelope-from ) id 1qRCzt-0007yB-FC; Wed, 02 Aug 2023 14:38:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 574978.900680; Wed, 02 Aug 2023 14:38:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRCzt-0007vk-7n; Wed, 02 Aug 2023 14:38:45 +0000 Received: by outflank-mailman (input) for mailman id 574978; Wed, 02 Aug 2023 14:38:43 +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 1qRCzr-0006bO-QZ for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 14:38:43 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 473a13cb-3142-11ee-b260-6b7b168915f2; Wed, 02 Aug 2023 16:38:42 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id EE2194EE073F; Wed, 2 Aug 2023 16:38:41 +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: 473a13cb-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 , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN PATCH 07/11] xen: address MISRA C:2012 Rule 2.1 Date: Wed, 2 Aug 2023 16:38:13 +0200 Message-Id: <7f8cbd8c8ad64cd3a0d099f31cb4d3fad48aa63b.1690985045.git.nicola.vetrini@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Rule 2.1 states: "A project shall not contain unreachable code". The functions - machine_halt - maybe_reboot - machine_restart are not supposed to return, hence the following break statement is marked as intentionally unreachable with the ASSERT_UNREACHABLE() macro to justify the violation of the rule. Signed-off-by: Nicola Vetrini --- xen/common/shutdown.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/xen/common/shutdown.c b/xen/common/shutdown.c index a933ee001e..88f735a30e 100644 --- a/xen/common/shutdown.c +++ b/xen/common/shutdown.c @@ -38,39 +38,45 @@ void hwdom_shutdown(u8 reason) printk("Hardware Dom%u halted: halting machine\n", hardware_domain->domain_id); machine_halt(); - break; /* not reached */ + ASSERT_UNREACHABLE(); + break; case SHUTDOWN_crash: debugger_trap_immediate(); printk("Hardware Dom%u crashed: ", hardware_domain->domain_id); kexec_crash(CRASHREASON_HWDOM); maybe_reboot(); - break; /* not reached */ + ASSERT_UNREACHABLE(); + break; case SHUTDOWN_reboot: printk("Hardware Dom%u shutdown: rebooting machine\n", hardware_domain->domain_id); machine_restart(0); - break; /* not reached */ + ASSERT_UNREACHABLE(); + break; case SHUTDOWN_watchdog: printk("Hardware Dom%u shutdown: watchdog rebooting machine\n", hardware_domain->domain_id); kexec_crash(CRASHREASON_WATCHDOG); machine_restart(0); - break; /* not reached */ + ASSERT_UNREACHABLE(); + break; case SHUTDOWN_soft_reset: printk("Hardware domain %d did unsupported soft reset, rebooting.\n", hardware_domain->domain_id); machine_restart(0); - break; /* not reached */ + ASSERT_UNREACHABLE(); + break; default: printk("Hardware Dom%u shutdown (unknown reason %u): ", hardware_domain->domain_id, reason); maybe_reboot(); - break; /* not reached */ + ASSERT_UNREACHABLE(); + break; } }