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);
{
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);
}
#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);
va_end(ap);
*path = virBufferContentAndReset(&buf);
- if (*path == NULL)
- ret = -1;
-
- return ret;
}
/* Read no more than the specified maximum number of bytes. */
/* 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;
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);
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;
*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,
*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 */