From nobody Thu Sep 19 02:04:39 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 1719310501114220.46941921838197; Tue, 25 Jun 2024 03:15:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.747548.1154993 (Exim 4.92) (envelope-from ) id 1sM3CI-0007mE-Gv; Tue, 25 Jun 2024 10:14:46 +0000 Received: by outflank-mailman (output) from mailman id 747548.1154993; Tue, 25 Jun 2024 10:14:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sM3CI-0007m7-ET; Tue, 25 Jun 2024 10:14:46 +0000 Received: by outflank-mailman (input) for mailman id 747548; Tue, 25 Jun 2024 10:14:45 +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 1sM3CH-0007WK-H4 for xen-devel@lists.xenproject.org; Tue, 25 Jun 2024 10:14:45 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id be0c93ce-32db-11ef-b4bb-af5377834399; Tue, 25 Jun 2024 12:14:44 +0200 (CEST) Received: from delta.bugseng.com.homenet.telecomitalia.it (host-87-17-171-46.retail.telecomitalia.it [87.17.171.46]) by support.bugseng.com (Postfix) with ESMTPSA id 899554EE073D; Tue, 25 Jun 2024 12:14:41 +0200 (CEST) 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: be0c93ce-32db-11ef-b4bb-af5377834399 From: Alessandro Zucchelli To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Alessandro Zucchelli , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH 1/3] common/kernel: address violation of MISRA C Rule 13.6 Date: Tue, 25 Jun 2024 12:14:19 +0200 Message-Id: <54949b0561263b9f18da500255836d89ca8838ba.1719308599.git.alessandro.zucchelli@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: 1719310503285100001 Content-Type: text/plain; charset="utf-8" In the file common/kernel.c macro ARRAY_SIZE is called with argument current->domain->handle. Once expanded, this ARRAY_SIZE's argument is used in sizeof operations and thus 'current', being a macro that expands to a function call with potential side effects, generates a violation. To address this violation the value of current->domain is therefore stored in a variable called 'd' before passing it to macro ARRAY_SIZE. No functional change. Signed-off-by: Alessandro Zucchelli --- xen/common/kernel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/common/kernel.c b/xen/common/kernel.c index b44b2439ca..76b4f27aef 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -660,14 +660,15 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(v= oid) arg) =20 case XENVER_guest_handle: { + struct domain *d =3D current->domain; xen_domain_handle_t hdl; =20 if ( deny ) memset(&hdl, 0, ARRAY_SIZE(hdl)); =20 - BUILD_BUG_ON(ARRAY_SIZE(current->domain->handle) !=3D ARRAY_SIZE(h= dl)); + BUILD_BUG_ON(ARRAY_SIZE(d->handle) !=3D ARRAY_SIZE(hdl)); =20 - if ( copy_to_guest(arg, deny ? hdl : current->domain->handle, + if ( copy_to_guest(arg, deny ? hdl : d->handle, ARRAY_SIZE(hdl) ) ) return -EFAULT; return 0; --=20 2.34.1