[PATCH 3/7] hw/s390x/ccw: Remove local Error variable from s390_ccw_realize()

Cédric Le Goater posted 7 patches 6 months ago
Maintainers: Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Tony Krowiak <akrowiak@linux.ibm.com>, Jason Herne <jjherne@linux.ibm.com>, Alex Williamson <alex.williamson@redhat.com>, "Cédric Le Goater" <clg@redhat.com>
[PATCH 3/7] hw/s390x/ccw: Remove local Error variable from s390_ccw_realize()
Posted by Cédric Le Goater 6 months ago
Use the 'Error **errp' argument of s390_ccw_realize() instead and
remove the error_propagate() call.

Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
 hw/s390x/s390-ccw.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c
index 4b8ede701df90949720262b6fc1b65f4e505e34d..b3d14c61d732880a651edcf28a040ca723cb9f5b 100644
--- a/hw/s390x/s390-ccw.c
+++ b/hw/s390x/s390-ccw.c
@@ -115,13 +115,12 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
     DeviceState *parent = DEVICE(ccw_dev);
     SubchDev *sch;
     int ret;
-    Error *err = NULL;
 
-    if (!s390_ccw_get_dev_info(cdev, sysfsdev, &err)) {
-        goto out_err_propagate;
+    if (!s390_ccw_get_dev_info(cdev, sysfsdev, errp)) {
+        return;
     }
 
-    sch = css_create_sch(ccw_dev->devno, &err);
+    sch = css_create_sch(ccw_dev->devno, errp);
     if (!sch) {
         goto out_mdevid_free;
     }
@@ -132,12 +131,12 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
     ccw_dev->sch = sch;
     ret = css_sch_build_schib(sch, &cdev->hostid);
     if (ret) {
-        error_setg_errno(&err, -ret, "%s: Failed to build initial schib",
+        error_setg_errno(errp, -ret, "%s: Failed to build initial schib",
                          __func__);
         goto out_err;
     }
 
-    if (!ck->realize(ccw_dev, &err)) {
+    if (!ck->realize(ccw_dev, errp)) {
         goto out_err;
     }
 
@@ -151,8 +150,6 @@ out_err:
     g_free(sch);
 out_mdevid_free:
     g_free(cdev->mdevid);
-out_err_propagate:
-    error_propagate(errp, err);
 }
 
 static void s390_ccw_unrealize(S390CCWDevice *cdev)
-- 
2.45.1


Re: [PATCH 3/7] hw/s390x/ccw: Remove local Error variable from s390_ccw_realize()
Posted by Anthony Krowiak 6 months ago
On 5/22/24 1:01 PM, Cédric Le Goater wrote:
> Use the 'Error **errp' argument of s390_ccw_realize() instead and
> remove the error_propagate() call.
>
> Signed-off-by: Cédric Le Goater <clg@redhat.com>


Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com>


> ---
>   hw/s390x/s390-ccw.c | 13 +++++--------
>   1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c
> index 4b8ede701df90949720262b6fc1b65f4e505e34d..b3d14c61d732880a651edcf28a040ca723cb9f5b 100644
> --- a/hw/s390x/s390-ccw.c
> +++ b/hw/s390x/s390-ccw.c
> @@ -115,13 +115,12 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
>       DeviceState *parent = DEVICE(ccw_dev);
>       SubchDev *sch;
>       int ret;
> -    Error *err = NULL;
>   
> -    if (!s390_ccw_get_dev_info(cdev, sysfsdev, &err)) {
> -        goto out_err_propagate;
> +    if (!s390_ccw_get_dev_info(cdev, sysfsdev, errp)) {
> +        return;
>       }
>   
> -    sch = css_create_sch(ccw_dev->devno, &err);
> +    sch = css_create_sch(ccw_dev->devno, errp);
>       if (!sch) {
>           goto out_mdevid_free;
>       }
> @@ -132,12 +131,12 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
>       ccw_dev->sch = sch;
>       ret = css_sch_build_schib(sch, &cdev->hostid);
>       if (ret) {
> -        error_setg_errno(&err, -ret, "%s: Failed to build initial schib",
> +        error_setg_errno(errp, -ret, "%s: Failed to build initial schib",
>                            __func__);
>           goto out_err;
>       }
>   
> -    if (!ck->realize(ccw_dev, &err)) {
> +    if (!ck->realize(ccw_dev, errp)) {
>           goto out_err;
>       }
>   
> @@ -151,8 +150,6 @@ out_err:
>       g_free(sch);
>   out_mdevid_free:
>       g_free(cdev->mdevid);
> -out_err_propagate:
> -    error_propagate(errp, err);
>   }
>   
>   static void s390_ccw_unrealize(S390CCWDevice *cdev)

RE: [PATCH 3/7] hw/s390x/ccw: Remove local Error variable from s390_ccw_realize()
Posted by Duan, Zhenzhong 6 months ago

>-----Original Message-----
>From: Cédric Le Goater <clg@redhat.com>
>Subject: [PATCH 3/7] hw/s390x/ccw: Remove local Error variable from
>s390_ccw_realize()
>
>Use the 'Error **errp' argument of s390_ccw_realize() instead and
>remove the error_propagate() call.
>
>Signed-off-by: Cédric Le Goater <clg@redhat.com>

Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>

Thanks
Zhenzhong

>---
> hw/s390x/s390-ccw.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
>diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c
>index
>4b8ede701df90949720262b6fc1b65f4e505e34d..b3d14c61d732880a651ed
>cf28a040ca723cb9f5b 100644
>--- a/hw/s390x/s390-ccw.c
>+++ b/hw/s390x/s390-ccw.c
>@@ -115,13 +115,12 @@ static void s390_ccw_realize(S390CCWDevice
>*cdev, char *sysfsdev, Error **errp)
>     DeviceState *parent = DEVICE(ccw_dev);
>     SubchDev *sch;
>     int ret;
>-    Error *err = NULL;
>
>-    if (!s390_ccw_get_dev_info(cdev, sysfsdev, &err)) {
>-        goto out_err_propagate;
>+    if (!s390_ccw_get_dev_info(cdev, sysfsdev, errp)) {
>+        return;
>     }
>
>-    sch = css_create_sch(ccw_dev->devno, &err);
>+    sch = css_create_sch(ccw_dev->devno, errp);
>     if (!sch) {
>         goto out_mdevid_free;
>     }
>@@ -132,12 +131,12 @@ static void s390_ccw_realize(S390CCWDevice
>*cdev, char *sysfsdev, Error **errp)
>     ccw_dev->sch = sch;
>     ret = css_sch_build_schib(sch, &cdev->hostid);
>     if (ret) {
>-        error_setg_errno(&err, -ret, "%s: Failed to build initial schib",
>+        error_setg_errno(errp, -ret, "%s: Failed to build initial schib",
>                          __func__);
>         goto out_err;
>     }
>
>-    if (!ck->realize(ccw_dev, &err)) {
>+    if (!ck->realize(ccw_dev, errp)) {
>         goto out_err;
>     }
>
>@@ -151,8 +150,6 @@ out_err:
>     g_free(sch);
> out_mdevid_free:
>     g_free(cdev->mdevid);
>-out_err_propagate:
>-    error_propagate(errp, err);
> }
>
> static void s390_ccw_unrealize(S390CCWDevice *cdev)
>--
>2.45.1