From nobody Sun May 12 20:36:14 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 1701430690702389.0749321385574; Fri, 1 Dec 2023 03:38:10 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.645484.1007665 (Exim 4.92) (envelope-from ) id 1r91qA-0001EP-3p; Fri, 01 Dec 2023 11:37:50 +0000 Received: by outflank-mailman (output) from mailman id 645484.1007665; Fri, 01 Dec 2023 11:37:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r91qA-0001EI-0p; Fri, 01 Dec 2023 11:37:50 +0000 Received: by outflank-mailman (input) for mailman id 645484; Fri, 01 Dec 2023 11:37:48 +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 1r91q8-0001EB-Pj for xen-devel@lists.xenproject.org; Fri, 01 Dec 2023 11:37:48 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0ccf9d35-903e-11ee-98e5-6d05b1d4d9a1; Fri, 01 Dec 2023 12:37:47 +0100 (CET) Received: from beta.station (net-37-182-35-120.cust.vodafonedsl.it [37.182.35.120]) by support.bugseng.com (Postfix) with ESMTPSA id 447C74EE073A; Fri, 1 Dec 2023 12:37: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: 0ccf9d35-903e-11ee-98e5-6d05b1d4d9a1 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, maria.celeste.cesario@bugseng.com, simone.ballarin@bugseng.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2] xen: address violations of MISRA C:2012 Rule 11.8. Date: Fri, 1 Dec 2023 12:37:04 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1701430692625000001 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario Remove or amend casts to comply with Rule 11.8. The violations are resolved either by adding missing const qualifiers in casts or by removing unnecessary cast. Change type of operands from char* to uintptr_t: uintptr_t is the appropriate type for memory address operations. No functional change. --- Changes in v2: - arm/regs.h: add const qualifier to the first operand, change types of both operands from char* to uintptr_t. - x86/regs.h: add const qualifier to both operands. Change types of both operands from char* to uintptr_t to conform with the arm version. - dom0less-build.c: rebase change in the new file. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin --- xen/arch/arm/dom0less-build.c | 2 +- xen/arch/arm/include/asm/atomic.h | 2 +- xen/arch/arm/include/asm/regs.h | 2 +- xen/arch/x86/include/asm/regs.h | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index d39cbd969a..fb63ec6fd1 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -354,7 +354,7 @@ static int __init handle_passthrough_prop(struct kernel= _info *kinfo, if ( node =3D=3D NULL ) { printk(XENLOG_ERR "Couldn't find node %s in host_dt!\n", - (char *)xen_path->data); + xen_path->data); return -EINVAL; } =20 diff --git a/xen/arch/arm/include/asm/atomic.h b/xen/arch/arm/include/asm/a= tomic.h index 64314d59b3..517216d2a8 100644 --- a/xen/arch/arm/include/asm/atomic.h +++ b/xen/arch/arm/include/asm/atomic.h @@ -154,7 +154,7 @@ static always_inline void write_atomic_size(volatile vo= id *p, */ static inline int atomic_read(const atomic_t *v) { - return *(volatile int *)&v->counter; + return *(const volatile int *)&v->counter; } =20 static inline int _atomic_read(atomic_t v) diff --git a/xen/arch/arm/include/asm/regs.h b/xen/arch/arm/include/asm/reg= s.h index 8a0db95415..b28eb5de7a 100644 --- a/xen/arch/arm/include/asm/regs.h +++ b/xen/arch/arm/include/asm/regs.h @@ -48,7 +48,7 @@ static inline bool regs_mode_is_32bit(const struct cpu_us= er_regs *regs) =20 static inline bool guest_mode(const struct cpu_user_regs *r) { - unsigned long diff =3D (char *)guest_cpu_user_regs() - (char *)(r); + unsigned long diff =3D (const uintptr_t)guest_cpu_user_regs() - (const= uintptr_t)(r); /* Frame pointer must point into current CPU stack. */ ASSERT(diff < STACK_SIZE); /* If not a guest frame, it must be a hypervisor frame. */ diff --git a/xen/arch/x86/include/asm/regs.h b/xen/arch/x86/include/asm/reg= s.h index 3fb94deedc..64f1e0d400 100644 --- a/xen/arch/x86/include/asm/regs.h +++ b/xen/arch/x86/include/asm/regs.h @@ -6,7 +6,8 @@ =20 #define guest_mode(r) = \ ({ = \ - unsigned long diff =3D (char *)guest_cpu_user_regs() - (char *)(r); = \ + unsigned long diff =3D (const uintptr_t)guest_cpu_user_regs() - = \ + (const uintptr_t(r= )); \ /* Frame pointer must point into current CPU stack. */ = \ ASSERT(diff < STACK_SIZE); = \ /* If not a guest frame, it must be a hypervisor frame. */ = \ --=20 2.40.0