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

[xen master] xen/common: address MISRA C:2012 Rule 5.3



commit 8d75d8069b8760d1a8d241f3581a1a1569b9aacf
Author:     Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
AuthorDate: Wed Aug 2 10:52:17 2023 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Aug 2 10:52:17 2023 +0200

    xen/common: address MISRA C:2012 Rule 5.3
    
    The following strategies are adopted to deal with violations
    of MISRA C:2012 Rule 5.3:
    "An identifier declared in an inner scope shall not hide an
    identifier declared in an outer scope".
    
    - s/nodes/numa_nodes/ for the file-scope variable in 'common/numa.c';
    - move the variable 'struct compat_remove_from_physmap cmp' inside
      the outer union variable 'cmp' to avoid shadowing it.
    
    Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/common/compat/memory.c |  7 +++----
 xen/common/numa.c          | 20 ++++++++++----------
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/xen/common/compat/memory.c b/xen/common/compat/memory.c
index 8ca63ceda6..8c34f201c2 100644
--- a/xen/common/compat/memory.c
+++ b/xen/common/compat/memory.c
@@ -81,6 +81,7 @@ int compat_memory_op(unsigned int cmd, 
XEN_GUEST_HANDLE_PARAM(void) compat)
             struct compat_memory_exchange xchg;
             struct compat_add_to_physmap atp;
             struct compat_add_to_physmap_batch atpb;
+            struct compat_remove_from_physmap xrfp;
             struct compat_vnuma_topology_info vnuma;
             struct compat_mem_access_op mao;
             struct compat_mem_acquire_resource mar;
@@ -321,12 +322,10 @@ int compat_memory_op(unsigned int cmd, 
XEN_GUEST_HANDLE_PARAM(void) compat)
 
         case XENMEM_remove_from_physmap:
         {
-            struct compat_remove_from_physmap cmp;
-
-            if ( copy_from_guest(&cmp, compat, 1) )
+            if ( copy_from_guest(&cmp.xrfp, compat, 1) )
                 return -EFAULT;
 
-            XLAT_remove_from_physmap(nat.xrfp, &cmp);
+            XLAT_remove_from_physmap(nat.xrfp, &cmp.xrfp);
 
             break;
         }
diff --git a/xen/common/numa.c b/xen/common/numa.c
index fc1f7f665b..f454c4d894 100644
--- a/xen/common/numa.c
+++ b/xen/common/numa.c
@@ -15,7 +15,7 @@
 
 static nodemask_t __initdata processor_nodes_parsed;
 static nodemask_t __initdata memory_nodes_parsed;
-static struct node __initdata nodes[MAX_NUMNODES];
+static struct node __initdata numa_nodes[MAX_NUMNODES];
 
 static unsigned int __ro_after_init num_node_memblks;
 static struct node __ro_after_init node_memblk_range[NR_NODE_MEMBLKS];
@@ -117,7 +117,7 @@ static enum conflicts __init conflicting_memblks(
 
 static void __init cutoff_node(nodeid_t i, paddr_t start, paddr_t end)
 {
-    struct node *nd = &nodes[i];
+    struct node *nd = &numa_nodes[i];
 
     if ( nd->start < start )
     {
@@ -157,7 +157,7 @@ bool __init numa_update_node_memblks(nodeid_t node, 
unsigned int arch_nid,
     paddr_t end = start + size;
     paddr_t nd_start = start;
     paddr_t nd_end = end;
-    struct node *nd = &nodes[node];
+    struct node *nd = &numa_nodes[node];
 
     /*
      * For the node that already has some memory blocks, we will
@@ -292,17 +292,17 @@ static bool __init nodes_cover_memory(void)
         do {
             found = false;
             for_each_node_mask ( j, memory_nodes_parsed )
-                if ( start < nodes[j].end && end > nodes[j].start )
+                if ( start < numa_nodes[j].end && end > numa_nodes[j].start )
                 {
-                    if ( start >= nodes[j].start )
+                    if ( start >= numa_nodes[j].start )
                     {
-                        start = nodes[j].end;
+                        start = numa_nodes[j].end;
                         found = true;
                     }
 
-                    if ( end <= nodes[j].end )
+                    if ( end <= numa_nodes[j].end )
                     {
-                        end = nodes[j].start;
+                        end = numa_nodes[j].start;
                         found = true;
                     }
                 }
@@ -356,10 +356,10 @@ static bool __init numa_process_nodes(paddr_t start, 
paddr_t end)
     /* Finally register nodes */
     for_each_node_mask ( i, all_nodes_parsed )
     {
-        if ( nodes[i].end == nodes[i].start )
+        if ( numa_nodes[i].end == numa_nodes[i].start )
             printk(KERN_INFO "NUMA: node %u has no memory\n", i);
 
-        setup_node_bootmem(i, nodes[i].start, nodes[i].end);
+        setup_node_bootmem(i, numa_nodes[i].start, numa_nodes[i].end);
     }
 
     for ( i = 0; i < nr_cpu_ids; i++ )
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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