The function can't fail nowadays, remove the return value and adjust callers. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- docs/internals/command.html.in | 8 +------- src/util/virfcp.c | 3 +-- src/util/virfile.c | 7 +------ src/util/virfile.h | 2 +- src/util/virhook.c | 14 ++------------ src/util/virpci.c | 11 ++--------- 6 files changed, 8 insertions(+), 37 deletions(-) diff --git a/docs/internals/command.html.in b/docs/internals/command.html.in index 823d89cc71..634afdc937 100644 --- a/docs/internals/command.html.in +++ b/docs/internals/command.html.in @@ -568,13 +568,7 @@ int runhook(const char *drvstr, const char *id, char *path; virCommandPtr cmd; - ret = virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr); - if ((ret < 0) || (path == NULL)) { - virHookReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to build path for %s hook"), - drvstr); - return -1; - } + virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr); cmd = virCommandNew(path); VIR_FREE(path); diff --git a/src/util/virfcp.c b/src/util/virfcp.c index 80773c7c5d..5e8fe72fec 100644 --- a/src/util/virfcp.c +++ b/src/util/virfcp.c @@ -40,8 +40,7 @@ virFCIsCapableRport(const char *rport) { g_autofree char *path = NULL; - if (virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport) < 0) - return false; + virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport); return virFileExists(path); } diff --git a/src/util/virfile.c b/src/util/virfile.c index 5710495bbf..27a647d1d0 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1308,13 +1308,12 @@ virFileFindMountPoint(const char *type G_GNUC_UNUSED) #endif /* defined WITH_MNTENT_H && defined WITH_GETMNTENT_R */ -int +void virBuildPathInternal(char **path, ...) { char *path_component = NULL; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; va_list ap; - int ret = 0; va_start(ap, path); @@ -1329,10 +1328,6 @@ virBuildPathInternal(char **path, ...) va_end(ap); *path = virBufferContentAndReset(&buf); - if (*path == NULL) - ret = -1; - - return ret; } /* Read no more than the specified maximum number of bytes. */ diff --git a/src/util/virfile.h b/src/util/virfile.h index 733d652ac9..f237e98290 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -300,7 +300,7 @@ char *virFileFindMountPoint(const char *type); /* NB: this should be combined with virFileBuildPath */ #define virBuildPath(path, ...) \ virBuildPathInternal(path, __VA_ARGS__, NULL) -int virBuildPathInternal(char **path, ...) G_GNUC_NULL_TERMINATED; +void virBuildPathInternal(char **path, ...) G_GNUC_NULL_TERMINATED; typedef struct _virHugeTLBFS virHugeTLBFS; typedef virHugeTLBFS *virHugeTLBFSPtr; diff --git a/src/util/virhook.c b/src/util/virhook.c index e4e1945225..b52e2cd814 100644 --- a/src/util/virhook.c +++ b/src/util/virhook.c @@ -155,12 +155,7 @@ virHookCheck(int no, const char *driver) return -1; } - if (virBuildPath(&path, LIBVIRT_HOOK_DIR, driver) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to build path for %s hook"), - driver); - return -1; - } + virBuildPath(&path, LIBVIRT_HOOK_DIR, driver); if (!virFileExists(path)) { VIR_DEBUG("No hook script %s", path); @@ -405,12 +400,7 @@ virHookCall(int driver, if (extra == NULL) extra = "-"; - if (virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to build path for %s hook"), - drvstr); - return -1; - } + virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr); script_ret = 1; diff --git a/src/util/virpci.c b/src/util/virpci.c index 3df4199532..515b642db4 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2293,10 +2293,7 @@ virPCIGetPhysicalFunction(const char *vf_sysfs_path, *pf = NULL; - if (virBuildPath(&device_link, vf_sysfs_path, "physfn") == -1) { - virReportOOMError(); - return -1; - } + virBuildPath(&device_link, vf_sysfs_path, "physfn"); if ((*pf = virPCIGetDeviceAddressFromSysfsLink(device_link))) { VIR_DEBUG("PF for VF device '%s': " VIR_PCI_DEVICE_ADDRESS_FMT, @@ -2470,11 +2467,7 @@ virPCIGetNetName(const char *device_link_sysfs_path, *netname = NULL; - if (virBuildPath(&pcidev_sysfs_net_path, device_link_sysfs_path, - "net") == -1) { - virReportOOMError(); - return -1; - } + virBuildPath(&pcidev_sysfs_net_path, device_link_sysfs_path, "net"); if (virDirOpenQuiet(&dir, pcidev_sysfs_net_path) < 0) { /* this *isn't* an error - caller needs to check for netname == NULL */ -- 2.29.2