From: "Cédric Le Goater" <clg@redhat.com>
To: Zhenzhong Duan <zhenzhong.duan@intel.com>, qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com
Subject: Re: [PATCH v2 06/11] vfio/container: Make vfio_connect_container() return bool
Date: Tue, 14 May 2024 18:00:18 +0200 [thread overview]
Message-ID: <d164d7b5-e7ac-4173-b2ef-0e49465ffa11@redhat.com> (raw)
In-Reply-To: <20240507064252.457884-7-zhenzhong.duan@intel.com>
On 5/7/24 08:42, Zhenzhong Duan wrote:
> This is to follow the coding standand to return bool if 'Error **'
> is used to pass error.
>
> Suggested-by: Cédric Le Goater <clg@redhat.com>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Thanks,
C.
> ---
> hw/vfio/container.c | 18 +++++++-----------
> 1 file changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
> index 85a8a369dc..0a7edfcc43 100644
> --- a/hw/vfio/container.c
> +++ b/hw/vfio/container.c
> @@ -534,8 +534,8 @@ static bool vfio_legacy_setup(VFIOContainerBase *bcontainer, Error **errp)
> return true;
> }
>
> -static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
> - Error **errp)
> +static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as,
> + Error **errp)
> {
> VFIOContainer *container;
> VFIOContainerBase *bcontainer;
> @@ -587,19 +587,18 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
> error_report("vfio: error disconnecting group %d from"
> " container", group->groupid);
> }
> - return ret;
> + return false;
> }
> group->container = container;
> QLIST_INSERT_HEAD(&container->group_list, group, container_next);
> vfio_kvm_device_add_group(group);
> - return 0;
> + return true;
> }
> }
>
> fd = qemu_open_old("/dev/vfio/vfio", O_RDWR);
> if (fd < 0) {
> error_setg_errno(errp, errno, "failed to open /dev/vfio/vfio");
> - ret = -errno;
> goto put_space_exit;
> }
>
> @@ -607,7 +606,6 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
> if (ret != VFIO_API_VERSION) {
> error_setg(errp, "supported vfio version: %d, "
> "reported version: %d", VFIO_API_VERSION, ret);
> - ret = -EINVAL;
> goto close_fd_exit;
> }
>
> @@ -634,7 +632,6 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
> assert(bcontainer->ops->setup);
>
> if (!bcontainer->ops->setup(bcontainer, errp)) {
> - ret = -EINVAL;
> goto enable_discards_exit;
> }
>
> @@ -650,7 +647,6 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
> memory_listener_register(&bcontainer->listener, bcontainer->space->as);
>
> if (bcontainer->error) {
> - ret = -1;
> error_propagate_prepend(errp, bcontainer->error,
> "memory listener initialization failed: ");
> goto listener_release_exit;
> @@ -658,7 +654,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
>
> bcontainer->initialized = true;
>
> - return 0;
> + return true;
> listener_release_exit:
> QLIST_REMOVE(group, container_next);
> QLIST_REMOVE(bcontainer, next);
> @@ -683,7 +679,7 @@ close_fd_exit:
> put_space_exit:
> vfio_put_address_space(space);
>
> - return ret;
> + return false;
> }
>
> static void vfio_disconnect_container(VFIOGroup *group)
> @@ -770,7 +766,7 @@ static VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp)
> group->groupid = groupid;
> QLIST_INIT(&group->device_list);
>
> - if (vfio_connect_container(group, as, errp)) {
> + if (!vfio_connect_container(group, as, errp)) {
> error_prepend(errp, "failed to setup container for group %d: ",
> groupid);
> goto close_fd_exit;
next prev parent reply other threads:[~2024-05-14 16:04 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-07 6:42 [PATCH v2 00/11] VFIO: misc cleanups Zhenzhong Duan
2024-05-07 6:42 ` [PATCH v2 01/11] vfio/pci: Use g_autofree in vfio_realize Zhenzhong Duan
2024-05-14 15:45 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 02/11] vfio/pci: Use g_autofree in iommufd_cdev_get_info_iova_range() Zhenzhong Duan
2024-05-14 15:45 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 03/11] vfio: Make VFIOIOMMUClass::attach_device() and its wrapper return bool Zhenzhong Duan
2024-05-07 7:27 ` Cédric Le Goater
2024-05-07 7:34 ` Duan, Zhenzhong
2024-05-15 16:28 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 04/11] vfio: Make VFIOIOMMUClass::setup() " Zhenzhong Duan
2024-05-07 6:42 ` [PATCH v2 05/11] vfio: Make VFIOIOMMUClass::add_window() and its wrapper " Zhenzhong Duan
2024-05-07 6:42 ` [PATCH v2 06/11] vfio/container: Make vfio_connect_container() " Zhenzhong Duan
2024-05-14 16:00 ` Cédric Le Goater [this message]
2024-05-07 6:42 ` [PATCH v2 07/11] vfio/container: Make vfio_set_iommu() " Zhenzhong Duan
2024-05-14 16:00 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 08/11] vfio/container: Make vfio_get_device() " Zhenzhong Duan
2024-05-14 16:01 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 09/11] vfio/iommufd: Make iommufd_cdev_*() " Zhenzhong Duan
2024-05-14 16:02 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 10/11] vfio/cpr: Make vfio_cpr_register_container() " Zhenzhong Duan
2024-05-14 16:02 ` Cédric Le Goater
2024-05-07 6:42 ` [PATCH v2 11/11] backends/iommufd: Make iommufd_backend_*() " Zhenzhong Duan
2024-05-14 16:03 ` Cédric Le Goater
2024-05-14 3:46 ` [PATCH v2 00/11] VFIO: misc cleanups Duan, Zhenzhong
2024-05-16 16:30 ` Cédric Le Goater
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=d164d7b5-e7ac-4173-b2ef-0e49465ffa11@redhat.com \
--to=clg@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=chao.p.peng@intel.com \
--cc=eric.auger@redhat.com \
--cc=qemu-devel@nongnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).