From nobody Wed Nov 27 21:52:02 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 1690454934548126.71086298567207; Thu, 27 Jul 2023 03:48:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.571010.893828 (Exim 4.92) (envelope-from ) id 1qOyXv-000833-Jv; Thu, 27 Jul 2023 10:48:39 +0000 Received: by outflank-mailman (output) from mailman id 571010.893828; Thu, 27 Jul 2023 10:48:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOyXv-00082V-FC; Thu, 27 Jul 2023 10:48:39 +0000 Received: by outflank-mailman (input) for mailman id 571010; Thu, 27 Jul 2023 10:48:38 +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 1qOyXu-00072A-EH for xen-devel@lists.xenproject.org; Thu, 27 Jul 2023 10:48:38 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 244a3d2d-2c6b-11ee-b247-6b7b168915f2; Thu, 27 Jul 2023 12:48:37 +0200 (CEST) Received: from nico.bugseng.com (unknown [37.161.207.213]) by support.bugseng.com (Postfix) with ESMTPSA id B13644EE0744; Thu, 27 Jul 2023 12:48:36 +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: 244a3d2d-2c6b-11ee-b247-6b7b168915f2 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, Nicola Vetrini , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [XEN PATCH 4/4] x86: avoid shadowing to address MISRA C:2012 Rule 5.3 Date: Thu, 27 Jul 2023 12:48:02 +0200 Message-Id: <10606d7429239b5a2b7dffcb22eeb1ce5e73e991.1690449587.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: 1690454935886100011 Content-Type: text/plain; charset="utf-8" Rule 5.3 has the following headline: "An identifier declared in an inner scope shall not hide an identifier declared in an outer scope" The declaration of local variable 'cpuid_leaf' causes shadowing with the homonymous function to happen, therefore the variable is renamed to avoid this. Local variable 'cr4' that shadows a previous declaration is removed, as it is unnecessary and doing so does not alter the semantics. Signed-off-by: Nicola Vetrini --- xen/arch/x86/x86_emulate/x86_emulate.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emul= ate/x86_emulate.c index 2de1be7996..9403beb20f 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -1483,7 +1483,7 @@ x86_emulate( { enum x86_segment seg; struct segment_register cs, sreg; - struct cpuid_leaf cpuid_leaf; + struct cpuid_leaf res; uint64_t msr_val; unsigned int i, n; unsigned long dummy; @@ -5024,13 +5024,13 @@ x86_emulate( generate_exception_if((msr_val & MSR_MISC_FEATURES_CPUID_FAULTING), X86_EXC_GP, 0); /* Faulting active? (Inc. CP= L test) */ =20 - rc =3D ops->cpuid(_regs.eax, _regs.ecx, &cpuid_leaf, ctxt); + rc =3D ops->cpuid(_regs.eax, _regs.ecx, &res, ctxt); if ( rc !=3D X86EMUL_OKAY ) goto done; - _regs.r(ax) =3D cpuid_leaf.a; - _regs.r(bx) =3D cpuid_leaf.b; - _regs.r(cx) =3D cpuid_leaf.c; - _regs.r(dx) =3D cpuid_leaf.d; + _regs.r(ax) =3D res.a; + _regs.r(bx) =3D res.b; + _regs.r(cx) =3D res.c; + _regs.r(dx) =3D res.d; break; =20 case X86EMUL_OPC(0x0f, 0xa3): bt: /* bt */ @@ -8408,8 +8408,6 @@ x86_emulate( generate_exception(X86_EXC_MF); if ( stub_exn.info.fields.trapnr =3D=3D X86_EXC_XM ) { - unsigned long cr4; - if ( !ops->read_cr || ops->read_cr(4, &cr4, ctxt) !=3D X86EMUL_OKA= Y ) cr4 =3D X86_CR4_OSXMMEXCPT; generate_exception(cr4 & X86_CR4_OSXMMEXCPT ? X86_EXC_XM : X86_EXC= _UD); --=20 2.34.1