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

[Xen-changelog] [xen-unstable] libxc: use a switch statement in xc_domain_restore.c::pagebuf_get_one.



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1283535780 -3600
# Node ID fc29ec1876047240a41a6775ac5d3532b2cf49d4
# Parent  30c74192c3613e90a715c729fd0087ac8f361f71
libxc: use a switch statement in xc_domain_restore.c::pagebuf_get_one.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxc/xc_domain_restore.c |   43 ++++++++++++++++++++++++++--------------
 1 files changed, 29 insertions(+), 14 deletions(-)

diff -r 30c74192c361 -r fc29ec187604 tools/libxc/xc_domain_restore.c
--- a/tools/libxc/xc_domain_restore.c   Fri Sep 03 18:41:37 2010 +0100
+++ b/tools/libxc/xc_domain_restore.c   Fri Sep 03 18:43:00 2010 +0100
@@ -680,14 +680,18 @@ static int pagebuf_get_one(xc_interface 
 
     // DPRINTF("reading batch of %d pages\n", count);
 
-    if (!count) {
+    switch ( count )
+    {
+    case 0:
         // DPRINTF("Last batch read\n");
         return 0;
-    } else if (count == XC_SAVE_ID_ENABLE_VERIFY_MODE) {
+
+    case XC_SAVE_ID_ENABLE_VERIFY_MODE:
         DPRINTF("Entering page verify mode\n");
         buf->verify = 1;
         return pagebuf_get_one(xch, ctx, buf, fd, dom);
-    } else if (count == XC_SAVE_ID_VCPU_INFO) {
+
+    case XC_SAVE_ID_VCPU_INFO:
         buf->new_ctxt_format = 1;
         if ( RDEXACT(fd, &buf->max_vcpu_id, sizeof(buf->max_vcpu_id)) ||
              buf->max_vcpu_id >= 64 || RDEXACT(fd, &buf->vcpumap,
@@ -697,7 +701,8 @@ static int pagebuf_get_one(xc_interface 
         }
         // DPRINTF("Max VCPU ID: %d, vcpumap: %llx\n", buf->max_vcpu_id, 
buf->vcpumap);
         return pagebuf_get_one(xch, ctx, buf, fd, dom);
-    } else if (count == XC_SAVE_ID_HVM_IDENT_PT) {
+
+    case XC_SAVE_ID_HVM_IDENT_PT:
         /* Skip padding 4 bytes then read the EPT identity PT location. */
         if ( RDEXACT(fd, &buf->identpt, sizeof(uint32_t)) ||
              RDEXACT(fd, &buf->identpt, sizeof(uint64_t)) )
@@ -707,7 +712,8 @@ static int pagebuf_get_one(xc_interface 
         }
         // DPRINTF("EPT identity map address: %llx\n", buf->identpt);
         return pagebuf_get_one(xch, ctx, buf, fd, dom);
-    } else if ( count == XC_SAVE_ID_HVM_VM86_TSS )  {
+
+    case XC_SAVE_ID_HVM_VM86_TSS:
         /* Skip padding 4 bytes then read the vm86 TSS location. */
         if ( RDEXACT(fd, &buf->vm86_tss, sizeof(uint32_t)) ||
              RDEXACT(fd, &buf->vm86_tss, sizeof(uint64_t)) )
@@ -717,21 +723,24 @@ static int pagebuf_get_one(xc_interface 
         }
         // DPRINTF("VM86 TSS location: %llx\n", buf->vm86_tss);
         return pagebuf_get_one(xch, ctx, buf, fd, dom);
-    } else if ( count == XC_SAVE_ID_TMEM ) {
+
+    case XC_SAVE_ID_TMEM:
         DPRINTF("xc_domain_restore start tmem\n");
         if ( xc_tmem_restore(xch, dom, fd) ) {
             PERROR("error reading/restoring tmem");
             return -1;
         }
         return pagebuf_get_one(xch, ctx, buf, fd, dom);
-    }
-    else if ( count == XC_SAVE_ID_TMEM_EXTRA ) {
+
+    case XC_SAVE_ID_TMEM_EXTRA:
         if ( xc_tmem_restore_extra(xch, dom, fd) ) {
             PERROR("error reading/restoring tmem extra");
             return -1;
         }
         return pagebuf_get_one(xch, ctx, buf, fd, dom);
-    } else if ( count == XC_SAVE_ID_TSC_INFO ) {
+
+    case XC_SAVE_ID_TSC_INFO:
+    {
         uint32_t tsc_mode, khz, incarn;
         uint64_t nsec;
         if ( RDEXACT(fd, &tsc_mode, sizeof(uint32_t)) ||
@@ -743,7 +752,9 @@ static int pagebuf_get_one(xc_interface 
             return -1;
         }
         return pagebuf_get_one(xch, ctx, buf, fd, dom);
-    } else if (count == XC_SAVE_ID_HVM_CONSOLE_PFN ) {
+    }
+
+    case XC_SAVE_ID_HVM_CONSOLE_PFN :
         /* Skip padding 4 bytes then read the console pfn location. */
         if ( RDEXACT(fd, &buf->console_pfn, sizeof(uint32_t)) ||
              RDEXACT(fd, &buf->console_pfn, sizeof(uint64_t)) )
@@ -753,10 +764,14 @@ static int pagebuf_get_one(xc_interface 
         }
         // DPRINTF("console pfn location: %llx\n", buf->console_pfn);
         return pagebuf_get_one(xch, ctx, buf, fd, dom);
-    } else if ( (count > MAX_BATCH_SIZE) || (count < 0) ) {
-        ERROR("Max batch size exceeded (%d). Giving up.", count);
-        errno = EMSGSIZE;
-        return -1;
+
+    default:
+        if ( (count > MAX_BATCH_SIZE) || (count < 0) ) {
+            ERROR("Max batch size exceeded (%d). Giving up.", count);
+            errno = EMSGSIZE;
+            return -1;
+        }
+        break;
     }
 
     oldcount = buf->nr_pages;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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