From: "Duan, Zhenzhong" <zhenzhong.duan@intel.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "alex.williamson@redhat.com" <alex.williamson@redhat.com>,
"clg@redhat.com" <clg@redhat.com>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"Peng, Chao P" <chao.p.peng@intel.com>,
"Markus Armbruster" <armbru@redhat.com>
Subject: RE: [PATCH v2 00/11] VFIO: misc cleanups
Date: Tue, 14 May 2024 03:46:01 +0000 [thread overview]
Message-ID: <SJ0PR11MB6744B042C01BF5CE7C8FA0C492E32@SJ0PR11MB6744.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20240507064252.457884-1-zhenzhong.duan@intel.com>
Hi All,
When I looked into more functions passing 'Error **',
I see many are in "int testfunc(..., Error **errp)" format. I was a bit confused.
The qapi/error.h suggests:
* - Whenever practical, also return a value that indicates success /
* failure. This can make the error checking more concise, and can
* avoid useless error object creation and destruction. Note that
* we still have many functions returning void. We recommend
* • bool-valued functions return true on success / false on failure,
* • pointer-valued functions return non-null / null pointer, and
* • integer-valued functions return non-negative / negative.
There are some functions like:
int testfunc(..., Error **errp)
{
If (succeed) {
return 0;
} else {
return -EINVAL;
}
}
Does testfunc() follow 'integer-valued functions' as above or it should be changed to 'bool-valued functions'?
Is there a clear rule in which case to change 'int testfunc(... Error **errp)' to ' bool testfunc(... Error **errp)'?
Thanks
Zhenzhong
>-----Original Message-----
>From: Duan, Zhenzhong <zhenzhong.duan@intel.com>
><zhenzhong.duan@intel.com>
>Subject: [PATCH v2 00/11] VFIO: misc cleanups
>
>Hi
>
>This is a cleanup series to change functions in hw/vfio/ to return bool
>when the error is passed through errp parameter, also some cleanup
>with g_autofree.
>
>See discussion at https://lists.gnu.org/archive/html/qemu-devel/2024-
>04/msg04782.html
>
>This series processed below files:
>hw/vfio/container.c
>hw/vfio/iommufd.c
>hw/vfio/cpr.c
>backends/iommufd.c
>
>So above files are clean now, there are still other files need processing
>in hw/vfio.
>
>Test done on x86 platform:
>vfio device hotplug/unplug with different backend
>reboot
>
>Thanks
>Zhenzhong
>
>Changelog:
>v2:
>- split out g_autofree code as a patch (Cédric)
>- add processing for more files
>
>Zhenzhong Duan (11):
> vfio/pci: Use g_autofree in vfio_realize
> vfio/pci: Use g_autofree in iommufd_cdev_get_info_iova_range()
> vfio: Make VFIOIOMMUClass::attach_device() and its wrapper return bool
> vfio: Make VFIOIOMMUClass::setup() return bool
> vfio: Make VFIOIOMMUClass::add_window() and its wrapper return bool
> vfio/container: Make vfio_connect_container() return bool
> vfio/container: Make vfio_set_iommu() return bool
> vfio/container: Make vfio_get_device() return bool
> vfio/iommufd: Make iommufd_cdev_*() return bool
> vfio/cpr: Make vfio_cpr_register_container() return bool
> backends/iommufd: Make iommufd_backend_*() return bool
>
> include/hw/vfio/vfio-common.h | 6 +-
> include/hw/vfio/vfio-container-base.h | 18 ++---
> include/sysemu/iommufd.h | 6 +-
> backends/iommufd.c | 29 +++----
> hw/vfio/ap.c | 6 +-
> hw/vfio/ccw.c | 6 +-
> hw/vfio/common.c | 6 +-
> hw/vfio/container-base.c | 8 +-
> hw/vfio/container.c | 81 +++++++++----------
> hw/vfio/cpr.c | 4 +-
> hw/vfio/iommufd.c | 109 +++++++++++---------------
> hw/vfio/pci.c | 12 ++-
> hw/vfio/platform.c | 7 +-
> hw/vfio/spapr.c | 28 +++----
> backends/trace-events | 4 +-
> 15 files changed, 147 insertions(+), 183 deletions(-)
>
>--
>2.34.1
next prev parent reply other threads:[~2024-05-14 3:47 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
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 ` Duan, Zhenzhong [this message]
2024-05-16 16:30 ` [PATCH v2 00/11] VFIO: misc cleanups 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=SJ0PR11MB6744B042C01BF5CE7C8FA0C492E32@SJ0PR11MB6744.namprd11.prod.outlook.com \
--to=zhenzhong.duan@intel.com \
--cc=alex.williamson@redhat.com \
--cc=armbru@redhat.com \
--cc=chao.p.peng@intel.com \
--cc=clg@redhat.com \
--cc=eric.auger@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).