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

Re: [XEN PATCH v2 1/4] x86: mechanically rename to address MISRA C:2012 Rule 5.3


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 31 Jul 2023 13:15:52 +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=uW3wYiVE6b/d+k8szt4QcKxk2XNHcpGVcLcMiq8XMyo=; b=ZKTWy15k64Irs+QRNKGq45yueqv1JL458XAhmjLXnsmypATGG3n6ex5dp38PueTwkbpfBlsXZd3JaniZVhy0lMTH0J4RUiT41MVZk6IRJ16cfM9LzmgoaofRwdnX5IPdI4QWEkQeZzY0f/dRaWzvmImaaZPqPVWgO9rEWzV7oo6aNrfFHQb333sZJs3elwploCHsKojaWoKumxWcpw5bT1VIzoGzG7Uidm1PPDHZ2fSJNUZUcm/PmgKDUmXVpx28gu3GB+lwL8yJWSFGsrHvSOJpY75pEEsB0FhduuVVc9+6+dY4vOYT/vJ24mKehwPW9qjmaypB23gzuIMbjCO3xg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F1N1lOn2c1YkqRKSziklm8UxLFfGhkW9X5NUeoRM6Uu/erUOHge0YFc+rSpuZKJqQnjGGiNkVbUVpLGWXzLm+uxBoEBkApYAGomQybCPklgj88P/x+1CNSXBobFWl/BXffi/5X4DSNSPTuZGdhDwRHU7CtLvIdqV2gLfLLb6tMi5D0DOIWKRB0oW+fRW6Lw9RG5Z6HxhV6P4PoxHhDIVHbQx4HaZTWRaR/OrL3DSdI5YQbjWZC2rWuxUJxiCD/i8JU4IfaUi69GW8NiOHDD2hdsBo+8EvHNpXmGNb2WWFKLB1D3KYgds+UjCDfIAA5GBJEVQ4p25cDd2dxYAQpyFJQ==
  • 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: Mon, 31 Jul 2023 11:16:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 31.07.2023 09:33, Nicola Vetrini wrote:
> 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 renames done by this patch avoid shadowing from happening.
> They are as follows:
> - s/i/j/ in 'mce_action' (the shadowing here is due to macro
>   'x86_mcinfo_lookup' that defines 'i' as a loop counter)

Then that macro needs adjustment. Especially considering it's in a
public header: It's full of name space violations.

> --- a/xen/arch/x86/include/asm/hvm/save.h
> +++ b/xen/arch/x86/include/asm/hvm/save.h
> @@ -49,21 +49,21 @@ void _hvm_read_entry(struct hvm_domain_context *h,
>   */
>  #define _hvm_load_entry(_x, _h, _dst, _strict) ({                       \
>      int r;                                                              \
> -    struct hvm_save_descriptor *desc                                    \
> +    struct hvm_save_descriptor *descriptor                              \
>          = (struct hvm_save_descriptor *)&(_h)->data[(_h)->cur];         \
>      if ( (r = _hvm_check_entry((_h), HVM_SAVE_CODE(_x),                 \
>                 HVM_SAVE_LENGTH(_x), (_strict))) == 0 )                  \
>      {                                                                   \
>          _hvm_read_entry((_h), (_dst), HVM_SAVE_LENGTH(_x));             \
>          if ( HVM_SAVE_HAS_COMPAT(_x) &&                                 \
> -             desc->length != HVM_SAVE_LENGTH(_x) )                      \
> -            r = HVM_SAVE_FIX_COMPAT(_x, (_dst), desc->length);          \
> +             descriptor->length != HVM_SAVE_LENGTH(_x) )                \
> +            r = HVM_SAVE_FIX_COMPAT(_x, (_dst), descriptor->length);    \
>      }                                                                   \
>      else if (HVM_SAVE_HAS_COMPAT(_x)                                    \
>               && (r = _hvm_check_entry((_h), HVM_SAVE_CODE(_x),          \
>                         HVM_SAVE_LENGTH_COMPAT(_x), (_strict))) == 0 ) { \
>          _hvm_read_entry((_h), (_dst), HVM_SAVE_LENGTH_COMPAT(_x));      \
> -        r = HVM_SAVE_FIX_COMPAT(_x, (_dst), desc->length);              \
> +        r = HVM_SAVE_FIX_COMPAT(_x, (_dst), descriptor->length);        \
>      }                                                                   \
>      r; })

The macro-local variable gets too long for my taste, to be honest,
and it being improperly named anyway suggests it simply wants a
trailing underscore added. And then, since for a variable named "r"
the risk of shadowing is equally high, that one wants to gain a
trailing underscore as well imo. (And while at it, I personally
would also drop the leading underscores from the macro parameter
names. Furthermore I think it would be nice if at on the lines
touched anyway indentation was also corrected. Overall maybe best
if I submit a patch.)

Jan



 


Rackspace

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