diff mbox series

[03/15] ppc: Fix return value in cpu_post_load() error path

Message ID 20200914123505.612812-4-groug@kaod.org (mailing list archive)
State New, archived
Headers show
Series spapr: Error handling fixes and cleanups (round 2) | expand

Commit Message

Greg Kurz Sept. 14, 2020, 12:34 p.m. UTC
VMState handlers are supposed to return negative errno values on failure.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 target/ppc/machine.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Vladimir Sementsov-Ogievskiy Sept. 15, 2020, 9:50 a.m. UTC | #1
14.09.2020 15:34, Greg Kurz wrote:
> VMState handlers are supposed to return negative errno values on failure.

Even vmstate_load_state() itself hase both "return -EINVAL" and "return -1".. So, all it's a mess)

> 
> Signed-off-by: Greg Kurz<groug@kaod.org>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Philippe Mathieu-Daudé Sept. 15, 2020, 1:01 p.m. UTC | #2
On 9/14/20 2:34 PM, Greg Kurz wrote:
> VMState handlers are supposed to return negative errno values on failure.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
>  target/ppc/machine.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff mbox series

Patch

diff --git a/target/ppc/machine.c b/target/ppc/machine.c
index 109d0711628f..5e5837737679 100644
--- a/target/ppc/machine.c
+++ b/target/ppc/machine.c
@@ -347,18 +347,19 @@  static int cpu_post_load(void *opaque, int version_id)
     if (cpu->compat_pvr) {
         uint32_t compat_pvr = cpu->compat_pvr;
         Error *local_err = NULL;
+        int ret;
 
         cpu->compat_pvr = 0;
-        ppc_set_compat(cpu, compat_pvr, &local_err);
-        if (local_err) {
+        ret = ppc_set_compat(cpu, compat_pvr, &local_err);
+        if (ret < 0) {
             error_report_err(local_err);
-            return -1;
+            return ret;
         }
     } else
 #endif
     {
         if (!pvr_match(cpu, env->spr[SPR_PVR])) {
-            return -1;
+            return -EINVAL;
         }
     }