[XEN PATCH v2] x86/mm address violations of MISRA C:2012 Rule 5.3

Alessandro Zucchelli posted 1 patch 2 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/201625791b87a4ab20e6fb38642ed64f88ce8b2d.1725888742.git.alessandro.zucchelli@bugseng.com
xen/arch/x86/mm.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
[XEN PATCH v2] x86/mm address violations of MISRA C:2012 Rule 5.3
Posted by Alessandro Zucchelli 2 months, 3 weeks ago
This addresses violations of MISRA C:2012 Rule 5.3 which states as
following: An identifier declared in an inner scope shall not hide an
identifier declared in an outer scope.

In /x86/mm.c the object struct e820entry *e820 hides an identifier
with the same name declared in x86/include/asm/e820.h.

No functional change.

Signed-off-by: Alessandro Zucchelli <alessandro.zucchelli@bugseng.com>
---
Changes in v2:
- rebased against current staging tree

 xen/arch/x86/mm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index c735aaf0e8..d537a799bc 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4708,7 +4708,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
     {
         struct xen_foreign_memory_map fmap;
         struct domain *d;
-        struct e820entry *e820;
+        struct e820entry *e;
 
         if ( copy_from_guest(&fmap, arg, 1) )
             return -EFAULT;
@@ -4727,23 +4727,23 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
             return rc;
         }
 
-        e820 = xmalloc_array(e820entry_t, fmap.map.nr_entries);
-        if ( e820 == NULL )
+        e = xmalloc_array(e820entry_t, fmap.map.nr_entries);
+        if ( e == NULL )
         {
             rcu_unlock_domain(d);
             return -ENOMEM;
         }
 
-        if ( copy_from_guest(e820, fmap.map.buffer, fmap.map.nr_entries) )
+        if ( copy_from_guest(e, fmap.map.buffer, fmap.map.nr_entries) )
         {
-            xfree(e820);
+            xfree(e);
             rcu_unlock_domain(d);
             return -EFAULT;
         }
 
         spin_lock(&d->arch.e820_lock);
         xfree(d->arch.e820);
-        d->arch.e820 = e820;
+        d->arch.e820 = e;
         d->arch.nr_e820 = fmap.map.nr_entries;
         spin_unlock(&d->arch.e820_lock);
 
-- 
2.34.1
Re: [XEN PATCH v2] x86/mm address violations of MISRA C:2012 Rule 5.3
Posted by Jan Beulich 2 months, 3 weeks ago
On 09.09.2024 15:36, Alessandro Zucchelli wrote:
> This addresses violations of MISRA C:2012 Rule 5.3 which states as
> following: An identifier declared in an inner scope shall not hide an
> identifier declared in an outer scope.
> 
> In /x86/mm.c the object struct e820entry *e820 hides an identifier
> with the same name declared in x86/include/asm/e820.h.
> 
> No functional change.
> 
> Signed-off-by: Alessandro Zucchelli <alessandro.zucchelli@bugseng.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
Re: [XEN PATCH v2] x86/mm address violations of MISRA C:2012 Rule 5.3
Posted by Frediano Ziglio 2 months, 3 weeks ago
On Mon, Sep 9, 2024 at 2:36 PM Alessandro Zucchelli <
alessandro.zucchelli@bugseng.com> wrote:

> This addresses violations of MISRA C:2012 Rule 5.3 which states as
> following: An identifier declared in an inner scope shall not hide an
> identifier declared in an outer scope.
>
> In /x86/mm.c the object struct e820entry *e820 hides an identifier
> with the same name declared in x86/include/asm/e820.h.
>
> No functional change.
>
> Signed-off-by: Alessandro Zucchelli <alessandro.zucchelli@bugseng.com>
> ---
> Changes in v2:
> - rebased against current staging tree
>
>  xen/arch/x86/mm.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
> index c735aaf0e8..d537a799bc 100644
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -4708,7 +4708,7 @@ long arch_memory_op(unsigned long cmd,
> XEN_GUEST_HANDLE_PARAM(void) arg)
>      {
>          struct xen_foreign_memory_map fmap;
>          struct domain *d;
> -        struct e820entry *e820;
> +        struct e820entry *e;
>

Couldn't we use a more meaningful name, like e820entries?


>
>          if ( copy_from_guest(&fmap, arg, 1) )
>              return -EFAULT;
> @@ -4727,23 +4727,23 @@ long arch_memory_op(unsigned long cmd,
> XEN_GUEST_HANDLE_PARAM(void) arg)
>              return rc;
>          }
>
> -        e820 = xmalloc_array(e820entry_t, fmap.map.nr_entries);
> -        if ( e820 == NULL )
> +        e = xmalloc_array(e820entry_t, fmap.map.nr_entries);
> +        if ( e == NULL )
>          {
>              rcu_unlock_domain(d);
>              return -ENOMEM;
>          }
>
> -        if ( copy_from_guest(e820, fmap.map.buffer, fmap.map.nr_entries) )
> +        if ( copy_from_guest(e, fmap.map.buffer, fmap.map.nr_entries) )
>          {
> -            xfree(e820);
> +            xfree(e);
>              rcu_unlock_domain(d);
>              return -EFAULT;
>          }
>
>          spin_lock(&d->arch.e820_lock);
>          xfree(d->arch.e820);
> -        d->arch.e820 = e820;
> +        d->arch.e820 = e;
>          d->arch.nr_e820 = fmap.map.nr_entries;
>          spin_unlock(&d->arch.e820_lock);
>
>
Frediano
Re: [XEN PATCH v2] x86/mm address violations of MISRA C:2012 Rule 5.3
Posted by Jan Beulich 2 months, 3 weeks ago
On 09.09.2024 15:46, Frediano Ziglio wrote:
>> --- a/xen/arch/x86/mm.c
>> +++ b/xen/arch/x86/mm.c
>> @@ -4708,7 +4708,7 @@ long arch_memory_op(unsigned long cmd,
>> XEN_GUEST_HANDLE_PARAM(void) arg)
>>      {
>>          struct xen_foreign_memory_map fmap;
>>          struct domain *d;
>> -        struct e820entry *e820;
>> +        struct e820entry *e;
>>
> 
> Couldn't we use a more meaningful name, like e820entries?

No excessively long names please.

Jan