Skip to contentSkip to conversation

x86/mm address violations of MISRA C:2012 Rule 5.3

PATCH In review Alessandro Zucchelli 3 participants 4 messages Sep 9, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/mm address violations of MISRA C:2012 Rule 5.3

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.

---
Changes in v2:
- rebased against current staging tree

 xen/arch/x86/mm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
xen/arch/x86/mm.c +6 -6
index c735aaf0e8..d537a799bc 100644
@@ -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);
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 22 lines · Alessandro Zucchelli

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.

---
Changes in v2:
- rebased against current staging tree

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

xen/arch/x86/mm.c long arch_memory_op(unsigned long cmd, · line 4713

Quoted 7 lines
xen/arch/x86/mm.c +1 -1
@@ -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?

Quoted 24 lines
xen/arch/x86/mm.c +0 -0
         if ( copy_from_guest(&fmap, arg, 1) )
             return -EFAULT;
xen/arch/x86/mm.c +4 -4
@@ -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);

xen/arch/x86/mm.c long arch_memory_op(unsigned long cmd, · line 4749

Quoted 10 lines
xen/arch/x86/mm.c +1 -1
             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

#2 lore raw
Quoted 4 lines · Frediano Ziglio
Quoted 4 lines
xen/arch/x86/mm.c +0 -0
@@ -4708,7 +4708,7 @@ long arch_memory_op(unsigned long cmd,
 XEN_GUEST_HANDLE_PARAM(void) arg)
Quoted 8 lines

xen/arch/x86/mm.c long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 4712

Quoted 6 lines
xen/arch/x86/mm.c +1 -1
     {
         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

Acked-by on v2 1/1
#3 lore raw
In reply to Alessandro Zucchelli
Quoted 10 lines · Alessandro Zucchelli

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.