Message ID | 20240507064252.457884-1-zhenzhong.duan@intel.com |
---|---|
Headers | show |
Series | VFIO: misc cleanups | expand |
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
On 5/7/24 08:42, Zhenzhong Duan wrote: > 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 Applied to vfio-next. Thanks, C.