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

[XEN PATCH 08/11] xen: move declarations to address MISRA C:2012 Rule 2.1



Declarations between a switch statement guard and before
any case label are unreachable code, and hence violate Rule 2.1:
"A project shall not contain unreachable code".

Therefore the variable declarations are moved in the smallest enclosing
scope, near other variable definitions.

Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
---
 xen/common/compat/memory.c |  3 +--
 xen/common/domain.c        | 15 +++++++--------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/xen/common/compat/memory.c b/xen/common/compat/memory.c
index 8ca63ceda6..d4c4204119 100644
--- a/xen/common/compat/memory.c
+++ b/xen/common/compat/memory.c
@@ -85,13 +85,12 @@ int compat_memory_op(unsigned int cmd, 
XEN_GUEST_HANDLE_PARAM(void) compat)
             struct compat_mem_access_op mao;
             struct compat_mem_acquire_resource mar;
         } cmp;
+        xen_pfn_t *space;
 
         set_xen_guest_handle(nat.hnd, COMPAT_ARG_XLAT_VIRT_BASE);
         split = 0;
         switch ( op )
         {
-            xen_pfn_t *space;
-
         case XENMEM_increase_reservation:
         case XENMEM_decrease_reservation:
         case XENMEM_populate_physmap:
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 304aa04fa6..e3aeaf059d 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -401,6 +401,13 @@ static int domain_teardown(struct domain *d)
 {
     struct vcpu *v;
     int rc;
+    enum {
+        PROG_none,
+        PROG_gnttab_mappings,
+        PROG_vcpu_teardown,
+        PROG_arch_teardown,
+        PROG_done,
+    };
 
     BUG_ON(!d->is_dying);
 
@@ -435,14 +442,6 @@ static int domain_teardown(struct domain *d)
     case PROG_vcpu_ ## x:                       \
         v = d->teardown.vcpu
 
-        enum {
-            PROG_none,
-            PROG_gnttab_mappings,
-            PROG_vcpu_teardown,
-            PROG_arch_teardown,
-            PROG_done,
-        };
-
     case PROG_none:
         BUILD_BUG_ON(PROG_none != 0);
 
-- 
2.34.1




 


Rackspace

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