Patchwork [v2,10/12] savevm: update return value from qemu_savevm_state

login
register
mail settings
Submitter Pavel Hrdina
Date March 22, 2013, 1:16 p.m.
Message ID <668f2843d7a0c1aff3e4eb4a439c7734098bb724.1363957855.git.phrdina@redhat.com>
Download mbox | patch
Permalink /patch/230014/
State New
Headers show

Comments

Pavel Hrdina - March 22, 2013, 1:16 p.m.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 savevm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Eric Blake - March 26, 2013, 9:57 p.m.
On 03/22/2013 07:16 AM, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---

The commit message could usefully explain _why_ it is okay to collapse
all error values into one.  As written, the code appears accurate; and
the lone caller (do_savevm) handles the new semantics.  But this goes
back to my question in 9/10 - why not use errp as the witness, and
return void, instead of duplicating information?

>  savevm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/savevm.c b/savevm.c
> index 45d1b09..2e5f029 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1805,7 +1805,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
>      };
>  
>      if (qemu_savevm_state_blocked(errp)) {
> -        return -EINVAL;
> +        return -1;
>      }
>  
>      qemu_mutex_unlock_iothread();
> @@ -1826,7 +1826,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
>      if (ret != 0) {
>          qemu_savevm_state_cancel();
>      }
> -    return ret;
> +    return ret == 0 ? 0 : -1;
>  }
>  
>  static int qemu_save_device_state(QEMUFile *f)
>

Patch

diff --git a/savevm.c b/savevm.c
index 45d1b09..2e5f029 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1805,7 +1805,7 @@  static int qemu_savevm_state(QEMUFile *f, Error **errp)
     };
 
     if (qemu_savevm_state_blocked(errp)) {
-        return -EINVAL;
+        return -1;
     }
 
     qemu_mutex_unlock_iothread();
@@ -1826,7 +1826,7 @@  static int qemu_savevm_state(QEMUFile *f, Error **errp)
     if (ret != 0) {
         qemu_savevm_state_cancel();
     }
-    return ret;
+    return ret == 0 ? 0 : -1;
 }
 
 static int qemu_save_device_state(QEMUFile *f)