From: Markus Armbruster <armbru@redhat.com>
To: "Cédric Le Goater" <clg@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>,
Alex Williamson <alex.williamson@redhat.com>,
Eric Farman <farman@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
qemu-s390x@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] vfio/ccw: Use g_autofree variable
Date: Wed, 24 Apr 2024 15:27:32 +0200 [thread overview]
Message-ID: <87cyqeubzv.fsf@pond.sub.org> (raw)
In-Reply-To: <20240424125441.215953-1-clg@redhat.com> ("Cédric Le Goater"'s message of "Wed, 24 Apr 2024 14:54:41 +0200")
Cédric Le Goater <clg@redhat.com> writes:
> Also change the return value of vfio_ccw_register_irq_notifier() to be
> a bool since it takes and 'Error **' argument. See the qapi/error.h
> Rules section.
>
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
My comments on "[PATCH] vfio/ap: Use g_autofree variable" apply.
More inline.
> ---
> hw/vfio/ccw.c | 25 +++++++++++--------------
> 1 file changed, 11 insertions(+), 14 deletions(-)
>
> diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
> index 90e4a534371684c08e112364e1537eb8979f73f4..1c630f6e9abe93ae0c2b5615d4409669f096c8c9 100644
> --- a/hw/vfio/ccw.c
> +++ b/hw/vfio/ccw.c
> @@ -379,12 +379,12 @@ read_err:
> css_inject_io_interrupt(sch);
> }
>
> -static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
> +static bool vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
> unsigned int irq,
> Error **errp)
> {
> VFIODevice *vdev = &vcdev->vdev;
> - struct vfio_irq_info *irq_info;
> + g_autofree struct vfio_irq_info *irq_info = NULL;
> size_t argsz;
> int fd;
> EventNotifier *notifier;
> @@ -405,13 +405,13 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
> break;
> default:
> error_setg(errp, "vfio: Unsupported device irq(%d)", irq);
> - return;
> + return false;
> }
>
> if (vdev->num_irqs < irq + 1) {
> error_setg(errp, "vfio: IRQ %u not available (number of irqs %u)",
> irq, vdev->num_irqs);
> - return;
> + return false;
> }
>
> argsz = sizeof(*irq_info);
> @@ -421,14 +421,14 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
> if (ioctl(vdev->fd, VFIO_DEVICE_GET_IRQ_INFO,
> irq_info) < 0 || irq_info->count < 1) {
> error_setg_errno(errp, errno, "vfio: Error getting irq info");
> - goto out_free_info;
> + return false;
> }
>
> if (event_notifier_init(notifier, 0)) {
> error_setg_errno(errp, errno,
> "vfio: Unable to init event notifier for irq (%d)",
> irq);
> - goto out_free_info;
> + return false;
> }
>
> fd = event_notifier_get_fd(notifier);
> @@ -440,8 +440,7 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
> event_notifier_cleanup(notifier);
> }
>
> -out_free_info:
> - g_free(irq_info);
> + return true;
> }
>
> static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev,
> @@ -605,20 +604,18 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)
> goto out_region_err;
> }
>
> - vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX, &err);
> - if (err) {
> + if (!vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX, &err)) {
Please pass errp instead of &err.
> goto out_io_notifier_err;
> }
>
> if (vcdev->crw_region) {
> - vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX, &err);
> - if (err) {
> + if (!vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX,
> + &err)) {
Likewise.
> goto out_irq_notifier_err;
> }
> }
>
> - vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX, &err);
> - if (err) {
> + if (!vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX, &err)) {
> /*
> * Report this error, but do not make it a failing condition.
> * Lack of this IRQ in the host does not prevent normal operation.
Reviewed-by: Markus Armbruster <armbru@redhat.com>
prev parent reply other threads:[~2024-04-24 13:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 12:54 [PATCH] vfio/ccw: Use g_autofree variable Cédric Le Goater
2024-04-24 13:01 ` Thomas Huth
2024-04-24 13:27 ` Markus Armbruster [this message]
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=87cyqeubzv.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=clg@redhat.com \
--cc=farman@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=thuth@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.