[PATCH 06/15] spapr: Simplify error handling in do_client_architecture_support()

Greg Kurz posted 15 patches 5 years, 4 months ago
Maintainers: David Gibson <david@gibson.dropbear.id.au>
[PATCH 06/15] spapr: Simplify error handling in do_client_architecture_support()
Posted by Greg Kurz 5 years, 4 months ago
Use the return value of ppc_set_compat_all() to check failures,
which is preferred over hijacking local_err.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/ppc/spapr_hcall.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 885ea60778ba..607740150fa2 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1666,7 +1666,6 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,
     uint32_t cas_pvr;
     SpaprOptionVector *ov1_guest, *ov5_guest;
     bool guest_radix;
-    Error *local_err = NULL;
     bool raw_mode_supported = false;
     bool guest_xive;
     CPUState *cs;
@@ -1697,8 +1696,9 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,
 
     /* Update CPUs */
     if (cpu->compat_pvr != cas_pvr) {
-        ppc_set_compat_all(cas_pvr, &local_err);
-        if (local_err) {
+        Error *local_err = NULL;
+
+        if (ppc_set_compat_all(cas_pvr, &local_err) < 0) {
             /* We fail to set compat mode (likely because running with KVM PR),
              * but maybe we can fallback to raw mode if the guest supports it.
              */
@@ -1707,7 +1707,6 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,
                 return H_HARDWARE;
             }
             error_free(local_err);
-            local_err = NULL;
         }
     }
 
-- 
2.26.2


Re: [PATCH 06/15] spapr: Simplify error handling in do_client_architecture_support()
Posted by Vladimir Sementsov-Ogievskiy 5 years, 4 months ago
14.09.2020 15:34, Greg Kurz wrote:
> Use the return value of ppc_set_compat_all() to check failures,
> which is preferred over hijacking local_err.
> 
> Signed-off-by: Greg Kurz<groug@kaod.org>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

-- 
Best regards,
Vladimir

Re: [PATCH 06/15] spapr: Simplify error handling in do_client_architecture_support()
Posted by Philippe Mathieu-Daudé 5 years, 4 months ago
On 9/14/20 2:34 PM, Greg Kurz wrote:
> Use the return value of ppc_set_compat_all() to check failures,
> which is preferred over hijacking local_err.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
>  hw/ppc/spapr_hcall.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

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