From nobody Mon Feb 9 12:29:10 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 1708680970776717.431854909248; Fri, 23 Feb 2024 01:36:10 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.684707.1064752 (Exim 4.92) (envelope-from ) id 1rdRyD-0006RU-8h; Fri, 23 Feb 2024 09:35:53 +0000 Received: by outflank-mailman (output) from mailman id 684707.1064752; Fri, 23 Feb 2024 09:35:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rdRyD-0006RL-5w; Fri, 23 Feb 2024 09:35:53 +0000 Received: by outflank-mailman (input) for mailman id 684707; Fri, 23 Feb 2024 09:35:52 +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 1rdRyC-0006BX-2n for xen-devel@lists.xenproject.org; Fri, 23 Feb 2024 09:35:52 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id eeee753b-d22e-11ee-8a57-1f161083a0e0; Fri, 23 Feb 2024 10:35:51 +0100 (CET) Received: from nico.bugseng.com (unknown [46.228.253.196]) by support.bugseng.com (Postfix) with ESMTPSA id 4FDB34EE0C8A; Fri, 23 Feb 2024 10:35:50 +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: eeee753b-d22e-11ee-8a57-1f161083a0e0 From: Nicola Vetrini To: nicola.vetrini@bugseng.com, xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, consulting@bugseng.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN PATCH 2/2] xen/cpu: address MISRA C Rule 17.7 Date: Fri, 23 Feb 2024 10:35:37 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1708680972112100005 Content-Type: text/plain; charset="utf-8" Refactor cpu_notifier_call_chain into two functions: - the variant that is allowed to fail loses the nofail flag - the variant that shouldn't fail is encapsulated in a call to the failing variant, with an additional check. This prevents uses of the function that are not supposed to fail from ignoring the return value, thus violating Rule 17.7: "The value returned by a function having non-void return type shall be used". No functional change. Signed-off-by: Nicola Vetrini Reviewed-by: Stefano Stabellini --- xen/common/cpu.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/xen/common/cpu.c b/xen/common/cpu.c index 8709db4d2957..0b7cf54c4264 100644 --- a/xen/common/cpu.c +++ b/xen/common/cpu.c @@ -78,20 +78,27 @@ void __init register_cpu_notifier(struct notifier_block= *nb) } =20 static int cpu_notifier_call_chain(unsigned int cpu, unsigned long action, - struct notifier_block **nb, bool nofail) + struct notifier_block **nb) { void *hcpu =3D (void *)(long)cpu; int notifier_rc =3D notifier_call_chain(&cpu_chain, action, hcpu, nb); int ret =3D notifier_to_errno(notifier_rc); =20 - BUG_ON(ret && nofail); - return ret; } =20 +static void cpu_notifier_call_chain_nofail(unsigned int cpu, + unsigned long action, + struct notifier_block **nb) +{ + int ret =3D cpu_notifier_call_chain(cpu, action, nb); + + BUG_ON(ret); +} + static void cf_check _take_cpu_down(void *unused) { - cpu_notifier_call_chain(smp_processor_id(), CPU_DYING, NULL, true); + cpu_notifier_call_chain_nofail(smp_processor_id(), CPU_DYING, NULL); __cpu_disable(); } =20 @@ -116,7 +123,7 @@ int cpu_down(unsigned int cpu) if ( !cpu_online(cpu) ) goto out; =20 - err =3D cpu_notifier_call_chain(cpu, CPU_DOWN_PREPARE, &nb, false); + err =3D cpu_notifier_call_chain(cpu, CPU_DOWN_PREPARE, &nb); if ( err ) goto fail; =20 @@ -129,14 +136,14 @@ int cpu_down(unsigned int cpu) err =3D cpu_online(cpu); BUG_ON(err); =20 - cpu_notifier_call_chain(cpu, CPU_DEAD, NULL, true); + cpu_notifier_call_chain_nofail(cpu, CPU_DEAD, NULL); =20 send_global_virq(VIRQ_PCPU_STATE); cpu_hotplug_done(); return 0; =20 fail: - cpu_notifier_call_chain(cpu, CPU_DOWN_FAILED, &nb, true); + cpu_notifier_call_chain_nofail(cpu, CPU_DOWN_FAILED, &nb); out: cpu_hotplug_done(); return err; @@ -157,7 +164,7 @@ int cpu_up(unsigned int cpu) if ( cpu_online(cpu) ) goto out; =20 - err =3D cpu_notifier_call_chain(cpu, CPU_UP_PREPARE, &nb, false); + err =3D cpu_notifier_call_chain(cpu, CPU_UP_PREPARE, &nb); if ( err ) goto fail; =20 @@ -165,7 +172,7 @@ int cpu_up(unsigned int cpu) if ( err < 0 ) goto fail; =20 - cpu_notifier_call_chain(cpu, CPU_ONLINE, NULL, true); + cpu_notifier_call_chain_nofail(cpu, CPU_ONLINE, NULL); =20 send_global_virq(VIRQ_PCPU_STATE); =20 @@ -173,7 +180,7 @@ int cpu_up(unsigned int cpu) return 0; =20 fail: - cpu_notifier_call_chain(cpu, CPU_UP_CANCELED, &nb, true); + cpu_notifier_call_chain_nofail(cpu, CPU_UP_CANCELED, &nb); out: cpu_hotplug_done(); return err; @@ -181,7 +188,7 @@ int cpu_up(unsigned int cpu) =20 void notify_cpu_starting(unsigned int cpu) { - cpu_notifier_call_chain(cpu, CPU_STARTING, NULL, true); + cpu_notifier_call_chain_nofail(cpu, CPU_STARTING, NULL); } =20 static cpumask_t frozen_cpus; @@ -237,7 +244,7 @@ void enable_nonboot_cpus(void) } =20 for_each_cpu ( cpu, &frozen_cpus ) - cpu_notifier_call_chain(cpu, CPU_RESUME_FAILED, NULL, true); + cpu_notifier_call_chain_nofail(cpu, CPU_RESUME_FAILED, NULL); =20 cpumask_clear(&frozen_cpus); } --=20 2.34.1