From: Michal Privoznik Date: Wed, 14 May 2025 14:14:39 +0000 (+0200) Subject: src: Fix retval of some functions declared to return an int X-Git-Tag: v11.4.0-rc1~70 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1e2b13fb2017b663670f211e9e08c6b124fba372;p=thirdparty%2Flibvirt.git src: Fix retval of some functions declared to return an int There are couple of functions (virCHDomainPrepareHostdevPCI(), qemuDomainPrepareHostdevPCI(), virStorageBackendRBDSetAllocation(), virCommandHandshakeChild()) that are declared to return an integer, but in fact return a boolean. This may lead to incorrect behaviour. Fix their retvals. This diff was generated using the following semantic patch: @@ identifier foo; @@ int foo(...) { <+... ( - return true; + return 0; | - return false; + return -1; ) ...+> } Each function and its callers were then inspected to see what retvals are expected. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- diff --git a/src/ch/ch_hostdev.c b/src/ch/ch_hostdev.c index 641032de30..34eb025c97 100644 --- a/src/ch/ch_hostdev.c +++ b/src/ch/ch_hostdev.c @@ -69,20 +69,20 @@ virCHDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev) if (!supportsPassthroughVFIO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("host doesn't support VFIO PCI passthrough")); - return false; + return -1; } break; case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("host doesn't support legacy PCI passthrough")); - return false; + return -1; case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("CH does not support device assignment mode '%1$s'"), virDeviceHostdevPCIDriverNameTypeToString(*driverName)); - return false; + return -1; default: case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: @@ -90,7 +90,7 @@ virCHDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev) break; } - return true; + return 0; } int diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index fd46c8be55..038a1a9e34 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -516,7 +516,7 @@ virStorageBackendRBDSetAllocation(virStorageVolDef *vol G_GNUC_UNUSED, rbd_image_info_t *info G_GNUC_UNUSED) { virReportUnsupportedError(); - return false; + return -1; } #endif diff --git a/src/util/vircommand.c b/src/util/vircommand.c index ea52acfbb8..d9e4c0181f 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -397,7 +397,7 @@ virCommandHandshakeChild(virCommand *cmd) int rv; if (!cmd->handshake) - return true; + return 0; VIR_DEBUG("Notifying parent for handshake start on %d", cmd->handshakeWait[1]);