From nobody Fri May 10 19:11:52 2024 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 1708680968542787.2996881710999; Fri, 23 Feb 2024 01:36:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.684706.1064742 (Exim 4.92) (envelope-from ) id 1rdRyB-0006CA-2f; Fri, 23 Feb 2024 09:35:51 +0000 Received: by outflank-mailman (output) from mailman id 684706.1064742; Fri, 23 Feb 2024 09:35:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rdRyA-0006C3-VV; Fri, 23 Feb 2024 09:35:50 +0000 Received: by outflank-mailman (input) for mailman id 684706; Fri, 23 Feb 2024 09:35:49 +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 1rdRy9-0006BX-1V for xen-devel@lists.xenproject.org; Fri, 23 Feb 2024 09:35:49 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ecdb525a-d22e-11ee-8a57-1f161083a0e0; Fri, 23 Feb 2024 10:35:48 +0100 (CET) Received: from nico.bugseng.com (unknown [46.228.253.196]) by support.bugseng.com (Postfix) with ESMTPSA id B667E4EE0741; Fri, 23 Feb 2024 10:35:46 +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: ecdb525a-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 1/2] xen/console: drop return value from consoled_guest_rx/tx Date: Fri, 23 Feb 2024 10:35:36 +0100 Message-Id: <4998ec735bd7e5a50a229507e2b92ae56ec1ba4b.1708680104.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: 1708680970260100003 Content-Type: text/plain; charset="utf-8" These functions never saw a usage of their return value since they were introduced, so it can be dropped since their usages violate MISRA C 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/drivers/char/consoled.c | 17 +++++------------ xen/include/xen/consoled.h | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/xen/drivers/char/consoled.c b/xen/drivers/char/consoled.c index 222e01844271..b415b632cecc 100644 --- a/xen/drivers/char/consoled.c +++ b/xen/drivers/char/consoled.c @@ -43,13 +43,13 @@ struct xencons_interface *consoled_get_ring_addr(void) static char buf[BUF_SZ + 1]; =20 /* Receives characters from a domain's PV console */ -size_t consoled_guest_rx(void) +void consoled_guest_rx(void) { - size_t recv =3D 0, idx =3D 0; + size_t idx =3D 0; XENCONS_RING_IDX cons, prod; =20 if ( !cons_ring ) - return 0; + return; =20 spin_lock(&rx_lock); =20 @@ -73,7 +73,6 @@ size_t consoled_guest_rx(void) char c =3D cons_ring->out[MASK_XENCONS_IDX(cons++, cons_ring->out)= ]; =20 buf[idx++] =3D c; - recv++; =20 if ( idx >=3D BUF_SZ ) { @@ -92,18 +91,15 @@ size_t consoled_guest_rx(void) =20 out: spin_unlock(&rx_lock); - - return recv; } =20 /* Sends a character into a domain's PV console */ -size_t consoled_guest_tx(char c) +void consoled_guest_tx(char c) { - size_t sent =3D 0; XENCONS_RING_IDX cons, prod; =20 if ( !cons_ring ) - return 0; + return; =20 cons =3D ACCESS_ONCE(cons_ring->in_cons); prod =3D cons_ring->in_prod; @@ -121,7 +117,6 @@ size_t consoled_guest_tx(char c) goto notify; =20 cons_ring->in[MASK_XENCONS_IDX(prod++, cons_ring->in)] =3D c; - sent++; =20 /* Write to the ring before updating the pointer */ smp_wmb(); @@ -130,8 +125,6 @@ size_t consoled_guest_tx(char c) notify: /* Always notify the guest: prevents receive path from getting stuck. = */ pv_shim_inject_evtchn(pv_console_evtchn()); - - return sent; } =20 /* diff --git a/xen/include/xen/consoled.h b/xen/include/xen/consoled.h index 2b30516b3a0a..bd7ab6329ee8 100644 --- a/xen/include/xen/consoled.h +++ b/xen/include/xen/consoled.h @@ -5,8 +5,8 @@ =20 void consoled_set_ring_addr(struct xencons_interface *ring); struct xencons_interface *consoled_get_ring_addr(void); -size_t consoled_guest_rx(void); -size_t consoled_guest_tx(char c); +void consoled_guest_rx(void); +void consoled_guest_tx(char c); =20 #endif /* __XEN_CONSOLED_H__ */ /* --=20 2.34.1 From nobody Fri May 10 19:11:52 2024 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