qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Cc: "Cédric Le Goater" <clg@redhat.com>,
	"Zhenzhong Duan" <zhenzhong.duan@intel.com>,
	"Anthony Krowiak" <akrowiak@linux.ibm.com>,
	"Eric Farman" <farman@linux.ibm.com>
Subject: [PULL 04/11] s390x/css: Make S390CCWDeviceClass::realize return bool
Date: Mon, 24 Jun 2024 11:10:36 +0200	[thread overview]
Message-ID: <20240624091043.177484-5-thuth@redhat.com> (raw)
In-Reply-To: <20240624091043.177484-1-thuth@redhat.com>

From: Cédric Le Goater <clg@redhat.com>

Since the realize() handler of S390CCWDeviceClass takes an 'Error **'
argument, best practices suggest to return a bool. See the api/error.h
Rules section. While at it, modify the call in vfio_ccw_realize().

Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20240522170107.289532-5-clg@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/hw/s390x/s390-ccw.h | 2 +-
 hw/s390x/s390-ccw.c         | 7 ++++---
 hw/vfio/ccw.c               | 3 +--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/hw/s390x/s390-ccw.h b/include/hw/s390x/s390-ccw.h
index 2c807ee3a1..2e0a709981 100644
--- a/include/hw/s390x/s390-ccw.h
+++ b/include/hw/s390x/s390-ccw.h
@@ -31,7 +31,7 @@ struct S390CCWDevice {
 
 struct S390CCWDeviceClass {
     CCWDeviceClass parent_class;
-    void (*realize)(S390CCWDevice *dev, char *sysfsdev, Error **errp);
+    bool (*realize)(S390CCWDevice *dev, char *sysfsdev, Error **errp);
     void (*unrealize)(S390CCWDevice *dev);
     IOInstEnding (*handle_request) (SubchDev *sch);
     int (*handle_halt) (SubchDev *sch);
diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c
index b3d14c61d7..3c09750550 100644
--- a/hw/s390x/s390-ccw.c
+++ b/hw/s390x/s390-ccw.c
@@ -108,7 +108,7 @@ static bool s390_ccw_get_dev_info(S390CCWDevice *cdev,
     return true;
 }
 
-static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
+static bool s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
 {
     CcwDevice *ccw_dev = CCW_DEVICE(cdev);
     CCWDeviceClass *ck = CCW_DEVICE_GET_CLASS(ccw_dev);
@@ -117,7 +117,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
     int ret;
 
     if (!s390_ccw_get_dev_info(cdev, sysfsdev, errp)) {
-        return;
+        return false;
     }
 
     sch = css_create_sch(ccw_dev->devno, errp);
@@ -142,7 +142,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
 
     css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
                           parent->hotplugged, 1);
-    return;
+    return true;
 
 out_err:
     css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL);
@@ -150,6 +150,7 @@ out_err:
     g_free(sch);
 out_mdevid_free:
     g_free(cdev->mdevid);
+    return false;
 }
 
 static void s390_ccw_unrealize(S390CCWDevice *cdev)
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 2600e62e37..9a8e052711 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -582,8 +582,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)
 
     /* Call the class init function for subchannel. */
     if (cdc->realize) {
-        cdc->realize(cdev, vcdev->vdev.sysfsdev, &err);
-        if (err) {
+        if (!cdc->realize(cdev, vcdev->vdev.sysfsdev, &err)) {
             goto out_err_propagate;
         }
     }
-- 
2.45.2



  parent reply	other threads:[~2024-06-24  9:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24  9:10 [PULL 00/11] s390x and qtest patches 2024-06-24 Thomas Huth
2024-06-24  9:10 ` [PULL 01/11] hw/s390x/ccw: Make s390_ccw_get_dev_info() return a bool Thomas Huth
2024-06-24  9:10 ` [PULL 02/11] s390x/css: Make CCWDeviceClass::realize return bool Thomas Huth
2024-06-24  9:10 ` [PULL 03/11] hw/s390x/ccw: Remove local Error variable from s390_ccw_realize() Thomas Huth
2024-06-24  9:10 ` Thomas Huth [this message]
2024-06-24  9:10 ` [PULL 05/11] vfio/ccw: Use the 'Error **errp' argument of vfio_ccw_realize() Thomas Huth
2024-06-24  9:10 ` [PULL 06/11] vfio/ccw: Fix the missed unrealize() call in error path Thomas Huth
2024-06-24  9:10 ` [PULL 07/11] vfio/{ap, ccw}: Use warn_report_err() for IRQ notifier registration errors Thomas Huth
2024-06-24  9:10 ` [PULL 08/11] tests/qtest/fuzz: fix memleak in qos_fuzz.c Thomas Huth
2024-06-24  9:10 ` [PULL 09/11] target/s390x/arch_dump: use correct byte order for pid Thomas Huth
2024-06-24  9:10 ` [PULL 10/11] MAINTAINERS: Cover all tests/qtest/migration-* files Thomas Huth
2024-06-24  9:10 ` [PULL 11/11] target/s390x: Add a CONFIG switch to disable legacy CPUs Thomas Huth
2025-03-07 15:27   ` Philippe Mathieu-Daudé
2025-03-07 15:33     ` Thomas Huth
2025-03-07 16:01       ` Philippe Mathieu-Daudé
2024-06-24 20:50 ` [PULL 00/11] s390x and qtest patches 2024-06-24 Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240624091043.177484-5-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=akrowiak@linux.ibm.com \
    --cc=clg@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=zhenzhong.duan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).