From patchwork Mon Dec 4 16:32:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simone Ballarin X-Patchwork-Id: 13478762 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 DE53CC4167B for ; Mon, 4 Dec 2023 16:34:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.647171.1009952 (Exim 4.92) (envelope-from ) id 1rABtr-0007Sq-IK; Mon, 04 Dec 2023 16:34:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 647171.1009952; Mon, 04 Dec 2023 16:34:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rABtr-0007Sj-FV; Mon, 04 Dec 2023 16:34:27 +0000 Received: by outflank-mailman (input) for mailman id 647171; Mon, 04 Dec 2023 16:34:25 +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 1rABtp-0007Sd-QN for xen-devel@lists.xenproject.org; Mon, 04 Dec 2023 16:34:25 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fb7b079a-92c2-11ee-9b0f-b553b5be7939; Mon, 04 Dec 2023 17:34:23 +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 889584EE073D; Mon, 4 Dec 2023 17:34:22 +0100 (CET) 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: fb7b079a-92c2-11ee-9b0f-b553b5be7939 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_Pau_Monn=C3=A9?= , Wei Liu Subject: [PATCH v3] xen: address violations of MISRA C:2012 Rule 11.8. Date: Mon, 4 Dec 2023 17:32:40 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 From: Maria Celeste Cesario Remove or amend casts to comply with Rule 11.8. Fix violations by adding missing const qualifier in cast. Fix violations 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 changes. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Acked-by: Jan Beulich Acked-by: Julien Grall --- Changes in v3: - drop const qualifier in both operands of the variable diff. - fix parentheses error. 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. --- 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 | 2 +- 4 files changed, 4 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 == NULL ) { printk(XENLOG_ERR "Couldn't find node %s in host_dt!\n", - (char *)xen_path->data); + xen_path->data); return -EINVAL; } diff --git a/xen/arch/arm/include/asm/atomic.h b/xen/arch/arm/include/asm/atomic.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 void *p, */ static inline int atomic_read(const atomic_t *v) { - return *(volatile int *)&v->counter; + return *(const volatile int *)&v->counter; } static inline int _atomic_read(atomic_t v) diff --git a/xen/arch/arm/include/asm/regs.h b/xen/arch/arm/include/asm/regs.h index 8a0db95415..f998aedff5 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_user_regs *regs) static inline bool guest_mode(const struct cpu_user_regs *r) { - unsigned long diff = (char *)guest_cpu_user_regs() - (char *)(r); + unsigned long diff = (uintptr_t)guest_cpu_user_regs() - (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/regs.h index 3fb94deedc..ddf5e14e57 100644 --- a/xen/arch/x86/include/asm/regs.h +++ b/xen/arch/x86/include/asm/regs.h @@ -6,7 +6,7 @@ #define guest_mode(r) \ ({ \ - unsigned long diff = (char *)guest_cpu_user_regs() - (char *)(r); \ + unsigned long diff = (uintptr_t)guest_cpu_user_regs() - (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. */ \