From nobody Mon Feb 9 18:48:48 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 1702894686801519.4449148367922; Mon, 18 Dec 2023 02:18:06 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.655802.1023598 (Exim 4.92) (envelope-from ) id 1rFAgw-0005LO-W2; Mon, 18 Dec 2023 10:17:42 +0000 Received: by outflank-mailman (output) from mailman id 655802.1023598; Mon, 18 Dec 2023 10:17:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFAgw-0005LD-TN; Mon, 18 Dec 2023 10:17:42 +0000 Received: by outflank-mailman (input) for mailman id 655802; Mon, 18 Dec 2023 10:17:41 +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 1rFAgv-00055P-Ki for xen-devel@lists.xenproject.org; Mon, 18 Dec 2023 10:17:41 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ac6cff72-9d8e-11ee-9b0f-b553b5be7939; Mon, 18 Dec 2023 11:17:40 +0100 (CET) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 81AEE4EE0747; Mon, 18 Dec 2023 11:17:38 +0100 (CET) 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: ac6cff72-9d8e-11ee-9b0f-b553b5be7939 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Nicola Vetrini , Simone Ballarin , Doug Goldstein , Stefano Stabellini , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN PATCH v2 1/7] xen/shutdown: address MISRA C:2012 Rule 2.1 Date: Mon, 18 Dec 2023 11:17:27 +0100 Message-Id: <22881ed8e7e28d66a730deb8812b6a4b7becc750.1702891792.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: 1702894688443100008 Content-Type: text/plain; charset="utf-8" Given that 'hwdom_shutdown' is a noreturn function, unreachable breaks can be eliminated to resolve violations of Rule 2.1. The rename s/maybe_reboot/reboot_or_halt/ is done to clarify that the function is noreturn. No functional change. Signed-off-by: Nicola Vetrini Reviewed-by: Stefano Stabellini --- Changes in v2: - rename maybe_reboot to reboot_or_halt. --- automation/eclair_analysis/ECLAIR/deviations.ecl | 2 +- xen/common/shutdown.c | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/= eclair_analysis/ECLAIR/deviations.ecl index 683f2bbfe89b..85741a2c01a9 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -16,7 +16,7 @@ Constant expressions and unreachable branches of if and s= witch statements are ex =20 -doc_begin=3D"Unreachability caused by calls to the following functions or= macros is deliberate and there is no risk of code being unexpectedly left = out." -config=3DMC3R1.R2.1,statements+=3D{deliberate,"macro(name(BUG||assert_fai= led))"} --config=3DMC3R1.R2.1,statements+=3D{deliberate, "call(decl(name(__builtin_= unreachable||panic||do_unexpected_trap||machine_halt||machine_restart||mayb= e_reboot)))"} +-config=3DMC3R1.R2.1,statements+=3D{deliberate, "call(decl(name(__builtin_= unreachable||panic||do_unexpected_trap||machine_halt||machine_restart||rebo= ot_or_halt)))"} -doc_end =20 -doc_begin=3D"Unreachability inside an ASSERT_UNREACHABLE() and analogous = macro calls is deliberate and safe." diff --git a/xen/common/shutdown.c b/xen/common/shutdown.c index 37901a4f3391..dfd5e41097e9 100644 --- a/xen/common/shutdown.c +++ b/xen/common/shutdown.c @@ -15,7 +15,7 @@ bool __read_mostly opt_noreboot; boolean_param("noreboot", opt_noreboot); =20 -static void noreturn maybe_reboot(void) +static void noreturn reboot_or_halt(void) { if ( opt_noreboot ) { @@ -38,39 +38,32 @@ void hwdom_shutdown(u8 reason) printk("Hardware Dom%u halted: halting machine\n", hardware_domain->domain_id); machine_halt(); - break; /* not reached */ =20 case SHUTDOWN_crash: debugger_trap_immediate(); printk("Hardware Dom%u crashed: ", hardware_domain->domain_id); kexec_crash(CRASHREASON_HWDOM); - maybe_reboot(); - break; /* not reached */ + reboot_or_halt(); =20 case SHUTDOWN_reboot: printk("Hardware Dom%u shutdown: rebooting machine\n", hardware_domain->domain_id); machine_restart(0); - break; /* not reached */ =20 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 */ =20 case SHUTDOWN_soft_reset: printk("Hardware domain %d did unsupported soft reset, rebooting.\= n", hardware_domain->domain_id); machine_restart(0); - break; /* not reached */ =20 default: printk("Hardware Dom%u shutdown (unknown reason %u): ", hardware_domain->domain_id, reason); - maybe_reboot(); - break; /* not reached */ + reboot_or_halt(); } -} =20 - +} --=20 2.34.1