virBuildPath: Remove return value

The function can't fail nowadays, remove the return value and adjust
callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Peter Krempa 2021-02-23 17:28:09 +01:00
parent e8d6a982b6
commit ccac1c2623
6 changed files with 8 additions and 37 deletions

View File

@ -568,13 +568,7 @@ int runhook(const char *drvstr, const char *id,
char *path;
virCommandPtr cmd;
ret = virBuildPath(&amp;path, LIBVIRT_HOOK_DIR, drvstr);
if ((ret &lt; 0) || (path == NULL)) {
virHookReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to build path for %s hook"),
drvstr);
return -1;
}
virBuildPath(&amp;path, LIBVIRT_HOOK_DIR, drvstr);
cmd = virCommandNew(path);
VIR_FREE(path);

View File

@ -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);
}

View File

@ -1307,13 +1307,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);
@ -1328,10 +1327,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. */

View File

@ -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;

View File

@ -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;

View File

@ -2304,10 +2304,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,
@ -2481,11 +2478,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 */