From nobody Thu May 16 04:43:50 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 1700209772953513.4205052758873; Fri, 17 Nov 2023 00:29:32 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.634872.990422 (Exim 4.92) (envelope-from ) id 1r3uDe-0001SC-T1; Fri, 17 Nov 2023 08:28:54 +0000 Received: by outflank-mailman (output) from mailman id 634872.990422; Fri, 17 Nov 2023 08:28:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r3uDe-0001S5-QT; Fri, 17 Nov 2023 08:28:54 +0000 Received: by outflank-mailman (input) for mailman id 634872; Fri, 17 Nov 2023 08:28:53 +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 1r3uDd-0001Rz-5V for xen-devel@lists.xenproject.org; Fri, 17 Nov 2023 08:28:53 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 555ee0bc-8523-11ee-9b0e-b553b5be7939; Fri, 17 Nov 2023 09:28:50 +0100 (CET) Received: from Dell.bugseng.com (unknown [37.163.77.7]) by support.bugseng.com (Postfix) with ESMTPSA id D519A4EE0744; Fri, 17 Nov 2023 09:28:47 +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: 555ee0bc-8523-11ee-9b0e-b553b5be7939 From: Federico Serafini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Federico Serafini , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu Subject: [XEN PATCH v3] xen: introduce function type bug_fn_t. Date: Fri, 17 Nov 2023 09:28:26 +0100 Message-Id: <3942021ff51b117ab2b50aecd6e75353cd73ab20.1700158707.git.federico.serafini@bugseng.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1700209775496100001 Content-Type: text/plain; charset="utf-8" Introduce function type bug_fn_t. This improves readability and helps to validate that the function passed to run_in_exception_handle() has the expected prototype. Use the newly-intoduced type to address a violation of MISRA C:2012 Rule 8.2. Suggested-by: Julien Grall Signed-off-by: Federico Serafini Acked-by: Julien Grall --- xen/arch/arm/traps.c | 2 +- xen/include/xen/bug.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index ce89f16404..8492e2b7bb 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1236,7 +1236,7 @@ int do_bug_frame(const struct cpu_user_regs *regs, va= ddr_t pc) =20 if ( id =3D=3D BUGFRAME_run_fn ) { - void (*fn)(const struct cpu_user_regs *) =3D (void *)regs->BUG_FN_= REG; + bug_fn_t *fn =3D (void *)regs->BUG_FN_REG; =20 fn(regs); return 0; diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h index e8a4eea71a..cb5138410e 100644 --- a/xen/include/xen/bug.h +++ b/xen/include/xen/bug.h @@ -99,6 +99,9 @@ struct bug_frame { =20 #endif =20 +struct cpu_user_regs; +typedef void bug_fn_t(const struct cpu_user_regs *regs); + #ifndef run_in_exception_handler =20 /* @@ -132,8 +135,6 @@ struct bug_frame { =20 #ifdef CONFIG_GENERIC_BUG_FRAME =20 -struct cpu_user_regs; - /* * Returns a negative value in case of an error otherwise * BUGFRAME_{run_fn, warn, bug, assert} --=20 2.34.1