Patchwork [01/42] migration: simplify while loop

login
register
mail settings
Submitter Paolo Bonzini
Date Feb. 22, 2013, 4:36 p.m.
Message ID <1361551008-12430-2-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/222555/
State New
Headers show

Comments

Paolo Bonzini - Feb. 22, 2013, 4:36 p.m.
Unify the goto around the loop, with the exit condition at the end of it.
Both can be expressed as "while (ret >= 0)".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 migration.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

Patch

diff --git a/migration.c b/migration.c
index 11725ae..ba8b647 100644
--- a/migration.c
+++ b/migration.c
@@ -666,14 +666,9 @@  static void *buffered_file_thread(void *opaque)
     qemu_mutex_lock_iothread();
     DPRINTF("beginning savevm\n");
     ret = qemu_savevm_state_begin(s->file, &s->params);
-    if (ret < 0) {
-        DPRINTF("failed, %d\n", ret);
-        qemu_mutex_unlock_iothread();
-        goto out;
-    }
     qemu_mutex_unlock_iothread();
 
-    while (true) {
+    while (ret >= 0) {
         int64_t current_time;
         uint64_t pending_size;
 
@@ -754,12 +749,8 @@  static void *buffered_file_thread(void *opaque)
             sleep_time += qemu_get_clock_ms(rt_clock) - current_time;
         }
         ret = buffered_flush(s);
-        if (ret < 0) {
-            break;
-        }
     }
 
-out:
     if (ret < 0) {
         migrate_fd_error(s);
     }