qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 2/5] vmstate: Replace while (...) with for (...)


From: Eduardo Habkost
Subject: [Qemu-devel] [PATCH 2/5] vmstate: Replace while (...) with for (...)
Date: Mon, 14 Oct 2013 13:45:45 -0300

This will make it easier to add code that skips some fields, by simply
using "continue".

Signed-off-by: Eduardo Habkost <address@hidden>
---
 savevm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/savevm.c b/savevm.c
index 208e7c2..9562669 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1676,7 +1676,7 @@ static int vmstate_subsection_load(QEMUFile *f, const 
VMStateDescription *vmsd,
 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                        void *opaque, int version_id)
 {
-    VMStateField *field = vmsd->fields;
+    VMStateField *field;
     int ret;
 
     if (version_id > vmsd->version_id) {
@@ -1693,7 +1693,7 @@ int vmstate_load_state(QEMUFile *f, const 
VMStateDescription *vmsd,
         if (ret)
             return ret;
     }
-    while(field->name) {
+    for (field = vmsd->fields; field->name; field++) {
         if ((field->field_exists &&
              field->field_exists(opaque, version_id)) ||
             (!field->field_exists &&
@@ -1740,7 +1740,6 @@ int vmstate_load_state(QEMUFile *f, const 
VMStateDescription *vmsd,
                 }
             }
         }
-        field++;
     }
     ret = vmstate_subsection_load(f, vmsd, opaque);
     if (ret != 0) {
@@ -1755,12 +1754,12 @@ int vmstate_load_state(QEMUFile *f, const 
VMStateDescription *vmsd,
 void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
                         void *opaque)
 {
-    VMStateField *field = vmsd->fields;
+    VMStateField *field;
 
     if (vmsd->pre_save) {
         vmsd->pre_save(opaque);
     }
-    while(field->name) {
+    for (field = vmsd->fields; field->name; field++) {
         if (!field->field_exists ||
             field->field_exists(opaque, vmsd->version_id)) {
             void *base_addr = opaque + field->offset;
@@ -1800,7 +1799,6 @@ void vmstate_save_state(QEMUFile *f, const 
VMStateDescription *vmsd,
                 }
             }
         }
-        field++;
     }
     vmstate_subsection_save(f, vmsd, opaque);
 }
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]