vfio/ap: Make vfio_ap_register_irq_notifier() return a bool
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/4 vfio/ap: Use g_autofree variable in vfio_ap_register_irq_notifier()
--- hw/vfio/ap.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
hw/vfio/ap.c +3 -7
@@ -77,7 +77,7 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,size_t argsz;IOHandler *fd_read;EventNotifier *notifier; -struct vfio_irq_info *irq_info; + g_autofree struct vfio_irq_info *irq_info = NULL;VFIODevice *vdev = &vapdev->vdev;switch (irq) {
@@ -104,14 +104,14 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,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 ; }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 ; } fd =event_notifier_get_fd (notifier);
@@ -122,10 +122,6 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,qemu_set_fd_handler (fd,NULL ,NULL , vapdev);event_notifier_cleanup (notifier); } - -out_free_info: -g_free (irq_info); - } static void vfio_ap_unregister_irq_notifier(VFIOAPDevice *vapdev,
Signature · 1 line
2.44.0
Re: [PATCH v2 1/4] vfio/ap: Use g_autofree variable in vfio_ap_register_irq_notifier()
Quoted 1 line · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>
Re: [PATCH v2 1/4] vfio/ap: Use g_autofree variable in vfio_ap_register_irq_notifier()
In reply to Cédric Le GoaterQuoted 4 lines · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>--- hw/vfio/ap.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
LGTM
Quoted 42 lines
hw/vfio/ap.c +3
-7@@ -77,7 +77,7 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,size_t argsz;IOHandler *fd_read;EventNotifier *notifier; -struct vfio_irq_info *irq_info; + g_autofree struct vfio_irq_info *irq_info = NULL;VFIODevice *vdev = &vapdev->vdev;switch (irq) {@@ -104,14 +104,14 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,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 ; }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 ; } fd =event_notifier_get_fd (notifier);@@ -122,10 +122,6 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,qemu_set_fd_handler (fd,NULL ,NULL , vapdev);event_notifier_cleanup (notifier); } - -out_free_info: -g_free (irq_info); - } static void vfio_ap_unregister_irq_notifier(VFIOAPDevice *vapdev,
Cédric Le Goater
AppliedRe: [PATCH v2 1/4] vfio/ap: Use g_autofree variable in vfio_ap_register_irq_notifier()
In reply to Cédric Le GoaterApplied series to vfio-next.
Thanks,
C.
Quoted 46 lines · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>--- hw/vfio/ap.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)hw/vfio/ap.c +3
-7@@ -77,7 +77,7 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,size_t argsz;IOHandler *fd_read;EventNotifier *notifier; -struct vfio_irq_info *irq_info; + g_autofree struct vfio_irq_info *irq_info = NULL;VFIODevice *vdev = &vapdev->vdev;switch (irq) {@@ -104,14 +104,14 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,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 ; }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 ; } fd =event_notifier_get_fd (notifier);@@ -122,10 +122,6 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,qemu_set_fd_handler (fd,NULL ,NULL , vapdev);event_notifier_cleanup (notifier); } - -out_free_info: -g_free (irq_info); - } static void vfio_ap_unregister_irq_notifier(VFIOAPDevice *vapdev,
PATCH v2 2/4 vfio/ap: Make vfio_ap_register_irq_notifier() return a bool
In reply to a message not in the archiveSince vfio_ap_register_irq_notifier() takes and 'Error **' argument, best practices suggest to return a bool. See the qapi/error.h Rules section.
--- hw/vfio/ap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
hw/vfio/ap.c +8 -7
@@ -70,7 +70,7 @@ static void vfio_ap_req_notifier_handler(void *opaque) } } -static void vfio_ap_register_irq_notifier (VFIOAPDevice *vapdev, +static bool vfio_ap_register_irq_notifier (VFIOAPDevice *vapdev,unsigned int irq,Error **errp) {int fd;
@@ -87,13 +87,13 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,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);
@@ -104,14 +104,14 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,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" ); -return ; +return false; }if (event_notifier_init (notifier,0 )) {error_setg_errno (errp, errno,"vfio: Unable to init event notifier for irq (%d)" , irq); -return ; +return false; } fd =event_notifier_get_fd (notifier);
@@ -122,6 +122,8 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,qemu_set_fd_handler (fd,NULL ,NULL , vapdev);event_notifier_cleanup (notifier); } + +return true; } static void vfio_ap_unregister_irq_notifier(VFIOAPDevice *vapdev,
@@ -167,8 +169,7 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp) goto error; } -vfio_ap_register_irq_notifier (vapdev,VFIO_AP_REQ_IRQ_INDEX , &err); -if (err) { +if (!vfio_ap_register_irq_notifier (vapdev,VFIO_AP_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.
Signature · 1 line
2.44.0
Quoted 65 lines · Cédric Le Goater
Since
vfio_ap_register_irq_notifier()takes and 'Error **' argument, best practices suggest to return a bool. See theqapi/error.hRules section.Signed-off-by Cédric Le Goater <[email protected]>--- hw/vfio/ap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)hw/vfio/ap.c +7
-5@@ -70,7 +70,7 @@ static void vfio_ap_req_notifier_handler(void *opaque) } } -static void vfio_ap_register_irq_notifier (VFIOAPDevice *vapdev, +static bool vfio_ap_register_irq_notifier (VFIOAPDevice *vapdev,unsigned int irq,Error **errp) {int fd;@@ -87,13 +87,13 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,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);@@ -104,14 +104,14 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,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" ); -return ; +return false; }if (event_notifier_init (notifier,0 )) {error_setg_errno (errp, errno,"vfio: Unable to init event notifier for irq (%d)" , irq); -return ; +return false; } fd =event_notifier_get_fd (notifier);@@ -122,6 +122,8 @@ static void vfio_ap_register_irq_notifier(VFIOAPDevice *vapdev,qemu_set_fd_handler (fd,NULL ,NULL , vapdev);event_notifier_cleanup (notifier); } + +return true; } static void vfio_ap_unregister_irq_notifier(VFIOAPDevice *vapdev,
hw/vfio/ap.c static void vfio_ap_realize(DeviceState *dev, Error **errp) · line 175
Quoted 9 lines
hw/vfio/ap.c +1
-2@@ -167,8 +169,7 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp) goto error; } -vfio_ap_register_irq_notifier (vapdev,VFIO_AP_REQ_IRQ_INDEX , &err); -if (err) { +if (!vfio_ap_register_irq_notifier (vapdev,VFIO_AP_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.
*/
error_report_err(err);Not this patch's problem, but here goes anyway: since this isn't an error, we shouldn't use error_report_err(). Would warn_report_err() be appropriate? info_report_err() doesn't exist, but it could.
This patch is fine as is, so
PATCH v2 3/4 vfio/ccw: Use g_autofree variable in vfio_ccw_register_irq_notifier()
In reply to a message not in the archive--- hw/vfio/ccw.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
hw/vfio/ccw.c +3 -6
@@ -384,7 +384,7 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev, 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;
@@ -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 ; }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 ; } fd =event_notifier_get_fd (notifier);
@@ -439,9 +439,6 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,qemu_set_fd_handler (fd,NULL ,NULL , vcdev);event_notifier_cleanup (notifier); } - -out_free_info: -g_free (irq_info); } static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev,
Signature · 1 line
2.44.0
Re: [PATCH v2 3/4] vfio/ccw: Use g_autofree variable in vfio_ccw_register_irq_notifier()
Quoted 1 line · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>
Re: [PATCH v2 3/4] vfio/ccw: Use g_autofree variable in vfio_ccw_register_irq_notifier()
In reply to Cédric Le GoaterQuoted 4 lines · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>---
hw/vfio/ccw.c | 9 +++------1 file changed, 3 insertions(+), 6 deletions(-)
I realize this was just split out of v1, but probably need a commit description here.
Regardless,
PATCH v2 4/4 vfio/ccw: Make vfio_ccw_register_irq_notifier() return a bool
In reply to a message not in the archiveSince vfio_ccw_register_irq_notifier() takes an 'Error **' argument, best practices suggest to return a bool. See the qapi/error.h Rules section.
--- hw/vfio/ccw.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
hw/vfio/ccw.c +11 -11
@@ -379,7 +379,7 @@ 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) {
@@ -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" ); -return ; +return false; }if (event_notifier_init (notifier,0 )) {error_setg_errno (errp, errno,"vfio: Unable to init event notifier for irq (%d)" , irq); -return ; +return false; } fd =event_notifier_get_fd (notifier);
@@ -439,6 +439,8 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,qemu_set_fd_handler (fd,NULL ,NULL , vcdev);event_notifier_cleanup (notifier); } + +return true; } static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev,
@@ -602,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)) { 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)) { 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.
Signature · 1 line
2.44.0
Re: [PATCH v2 4/4] vfio/ccw: Make vfio_ccw_register_irq_notifier() return a bool
Quoted 65 lines · Cédric Le Goater
Since
vfio_ccw_register_irq_notifier()takes an 'Error **' argument, best practices suggest to return a bool. See theqapi/error.hRules section.Signed-off-by Cédric Le Goater <[email protected]>--- hw/vfio/ccw.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)hw/vfio/ccw.c +7
-5@@ -379,7 +379,7 @@ 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) {@@ -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" ); -return ; +return false; }if (event_notifier_init (notifier,0 )) {error_setg_errno (errp, errno,"vfio: Unable to init event notifier for irq (%d)" , irq); -return ; +return false; } fd =event_notifier_get_fd (notifier);@@ -439,6 +439,8 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,qemu_set_fd_handler (fd,NULL ,NULL , vcdev);event_notifier_cleanup (notifier); } + +return true; } static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev,
hw/vfio/ccw.c static void vfio_ccw_realize(DeviceState *dev, Error **errp) · line 607
Quoted 6 lines
hw/vfio/ccw.c +1
-2@@ -602,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.
hw/vfio/ccw.c static void vfio_ccw_realize(DeviceState *dev, Error **errp) · line 613
Quoted 8 lines
hw/vfio/ccw.c +2
-2goto 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.
hw/vfio/ccw.c static void vfio_ccw_realize(DeviceState *dev, Error **errp) · line 621
Quoted 10 lines
hw/vfio/ccw.c +1
-2goto 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.
*/
error_report_err(err);Not this patch's problem, but here goes anyway: since this isn't an error, we shouldn't use error_report_err(). Would warn_report_err() be appropriate? info_report_err() doesn't exist, but it could.
Preferably with errp instead of &err (two times):
Eric Farman
Reviewed-byRe: [PATCH v2 4/4] vfio/ccw: Make vfio_ccw_register_irq_notifier() return a bool
Quoted 118 lines · Markus Armbruster
Quoted 77 lines · Cédric Le Goater
Since
vfio_ccw_register_irq_notifier()takes an 'Error **' argument,
best practices suggest to return a bool. See theqapi/error.hRules section.Signed-off-by Cédric Le Goater <[email protected]>---
hw/vfio/ccw.c | 22 +++++++++++-----------1 file changed, 11 insertions(+), 11 deletions(-)hw/vfio/ccw.c +0
-0index
6764388bc47a970329fce2233626ccb8178e0165..1c630f6e9abe93ae0c2b5615d4409669f096c8c9100644hw/vfio/ccw.c +0
-0@@ -379,7 +379,7 @@ read_err: css_inject_io_interrupt(sch); }hw/vfio/ccw.c +1
-1-static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev, +static bool vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,unsigned int irq, Error **errp) {
hw/vfio/ccw.c +0
-0@@ -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);hw/vfio/ccw.c +0
-0@@ -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");
- return;
+ return false;
}
if (event_notifier_init(notifier, 0)) { error_setg_errno(errp, errno,
"vfio: Unable to init event notifier for irq (%d)",
irq);
- return;
+ return false;
}
fd =event_notifier_get_fd(notifier);hw/vfio/ccw.c +2
-0@@ -439,6 +439,8 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev, qemu_set_fd_handler(fd, NULL, NULL, vcdev); event_notifier_cleanup(notifier); } + + return true; }
static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev,hw/vfio/ccw.c +0
-0@@ -602,20 +604,18 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp) goto out_region_err; }Quoted 6 lines
-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.
Quoted 10 lines
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.
Quoted 6 lines
goto
out_irq_notifier_err;
}
}
-vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX, &err);Quoted 8 lines
- 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.*/
error_report_err(err);
Quoted 8 lines
Not this patch's problem, but here goes anyway: since this isn't an error, we shouldn't use error_report_err(). Would
warn_report_err()be
appropriate?info_report_err()doesn't exist, but it could.Preferably with errp instead of &err (two times):
Reviewed-by Markus Armbruster <[email protected]>
Don't recall why I used error_report_err() instead of something else (or creating info_), but probably just familiarity. There's no need for it (or the equivalent code in -ap) to be error, and could be another cleanup.
Re: [PATCH v2 4/4] vfio/ccw: Make vfio_ccw_register_irq_notifier() return a bool
Quoted 124 lines · Eric Farman
Quoted 123 lines · Markus Armbruster
Quoted 74 lines · Cédric Le Goater
Since
vfio_ccw_register_irq_notifier()takes an 'Error **' argument,
best practices suggest to return a bool. See theqapi/error.hRules section.Signed-off-by Cédric Le Goater <[email protected]>--- hw/vfio/ccw.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)hw/vfio/ccw.c +0
-0index
6764388bc47a970329fce2233626ccb8178e0165..1c630f6e9abe93ae0c2b5615d4409669f096c8c9100644hw/vfio/ccw.c +3
-3@@ -379,7 +379,7 @@ 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) {@@ -405,13 +405,13 @@ static voidvfio_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);hw/vfio/ccw.c +2
-2@@ -421,14 +421,14 @@ static voidvfio_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"); - return; + return false; } if (event_notifier_init(notifier, 0)) { error_setg_errno(errp, errno, "vfio: Unable to init event notifier for irq (%d)", irq); - return; + return false;}
fd =
event_notifier_get_fd(notifier);hw/vfio/ccw.c +2
-0@@ -439,6 +439,8 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev, qemu_set_fd_handler(fd, NULL, NULL, vcdev); event_notifier_cleanup(notifier); } + + return true; }static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev,
hw/vfio/ccw.c static void vfio_ccw_realize(DeviceState · line 610
Quoted 9 lines
hw/vfio/ccw.c +1
-2@@ -602,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.
hw/vfio/ccw.c static void vfio_ccw_realize(DeviceState *dev, Error **errp) · line 613
Quoted 10 lines
hw/vfio/ccw.c +2
-2goto 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.
Quoted 6 lines
hw/vfio/ccw.c +0
-1goto out_irq_notifier_err; } } - vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX,&err);
Quoted 8 lines
- 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.*/
error_report_err(err);Not this patch's problem, but here goes anyway: since this isn't an error, we shouldn't use error_report_err(). Would
warn_report_err()be
appropriate?info_report_err()doesn't exist, but it could.
Quoted 8 lines
Quoted 3 lines
Preferably with errp instead of &err (two times):
Reviewed-by Markus Armbruster <[email protected]>Don't recall why I used
error_report_err()instead of something else (or creatinginfo_), but probably just familiarity. There's no need for it (or the equivalent code in -ap) to be error, and could be another cleanup.
yes. I will send an extra cleanup to replace error_... with warn_... and another one to use errp.
Thanks,
C.
Quoted 2 lines
Reviewed-by Eric Farman <[email protected]>