[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN PATCH 4/4] x86: avoid shadowing to address MISRA C:2012 Rule 5.3


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 27 Jul 2023 18:04:19 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xEF8FQiQ+SO2NIYaQhyQWbriRw5ddlRxpsLEwF3/2wc=; b=A1BISJVRzp/4GvSSGqLQelX9fMhySoQLqtxgkeIt7RUAF10gc85J0exow1fxSsrmSQIQXA2COFpioX8obPlro0TyUYrWfr3UTzWcJFZQnSdLvB5wHxqn+os8c5unDeBpAfLMFUhtRwJIQJXEzZgYH6tpkgFmljIv0bLV1Sr6nNRjNUkO9MrJnKDQZl59YpvMFtqAaoMwAz9ZTaNv3gYV/7Yc83Hnca1rAwoFrCH0qiida97YH/3Y5lYWZfMRVfMjzYWq+wtPDG4+0UHvh7dPJI4sfPaZ5YWmJncfo06R+NUNJS3uFxvtRg/WnepmWbvrj5x1vnKcRVv2x8fxA48lAg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JdZMsRFUt/xVHmN1kfruXLy+jK9QzAthJTRj2CqegqI2r/3ag/2wtwyWFw4ui9w9gb9P6gTeTr1gkB+yWR3gqAKF9LLdZDeSU1vPB0s5Hwd6gxu1OSkvD0l6ewtblDv9XOVaVbjAIH139CKP3mANKgwhYaLzZYm6/kFGDWbxveKk4jPpoqe6S2HUXa+GqTR8+IW1GGoGGUxzPaQs1AgsjjVd4LvvOuVBQeeeT5JWZBRPvOAvzG75iJ/iINfhvix+apVoKM1zOH9/VtK1ZnDsQ3SndO3I/j8FWeYB36W4ELveNzJIQn0iz51PAIdyRw5erW76qOzxzVQM0RHptHhEMQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: sstabellini@xxxxxxxxxx, michal.orzel@xxxxxxx, xenia.ragiadakou@xxxxxxx, ayan.kumar.halder@xxxxxxx, consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 27 Jul 2023 16:04:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27.07.2023 17:58, Nicola Vetrini wrote:
> 
> 
> On 27/07/23 17:41, Jan Beulich wrote:
>> On 27.07.2023 12:48, Nicola Vetrini wrote:
>>> --- 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;
>>
>> This is too generic a name for a variable with a scope of several
>> thousand lines. Perhaps just "leaf"?
> 
> It can also be defined inside the switch clause, since it has no other 
> purpose than store a result.

That would be more code churn, though.

>>> @@ -8408,8 +8408,6 @@ x86_emulate(
>>>           generate_exception(X86_EXC_MF);
>>>       if ( stub_exn.info.fields.trapnr == X86_EXC_XM )
>>>       {
>>> -        unsigned long cr4;
>>> -
>>>           if ( !ops->read_cr || ops->read_cr(4, &cr4, ctxt) != X86EMUL_OKAY 
>>> )
>>>               cr4 = X86_CR4_OSXMMEXCPT;
>>>           generate_exception(cr4 & X86_CR4_OSXMMEXCPT ? X86_EXC_XM : 
>>> X86_EXC_UD);
>>
>> This change looks okay to me, but I'd like to strongly encourage
>> you to split both changes. They're of different nature, and for
>> the latter it may even be worthwhile pointing out when exactly
>> this duplication of variables was introduced (it clearly would
>> better have been avoided).
>>
> 
> I did it this way because they are the only violations of R5.3 left in 
> this file (among those not subject to deviation). By splitting you mean 
> two patches in this series or a separate patch just for this change?

Separate or within a series doesn't matter. Just preferably not in
the same patch. (And btw, if you split larger patches more, some of
your changes may also go in more quickly. Yet of course this shouldn't
get too fine grained.)

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.