]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virBuildPath: Remove return value
authorPeter Krempa <pkrempa@redhat.com>
Tue, 23 Feb 2021 16:28:09 +0000 (17:28 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Mar 2021 08:50:19 +0000 (09:50 +0100)
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>
docs/internals/command.html.in
src/util/virfcp.c
src/util/virfile.c
src/util/virfile.h
src/util/virhook.c
src/util/virpci.c

index 823d89cc718121cd6c29c44ac1a935231bc11c04..634afdc93795218d32273f19a5ebccd81b17d30e 100644 (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);
index 80773c7c5d4477cdae47ec9b950efecef613da94..5e8fe72fec1d25b32278771deb4ee1ffa8dd1d87 100644 (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);
 }
index 7cb60e66d327fe2e328e6fc139b0dd2ad941bf1a..841a0f4e002580e07d882d77d58a30557fdf6335 100644 (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. */
index 733d652ac90c4ae30dd9a2f120e7c0aab198ab9f..f237e982900e1c54eaf9482093fa23d77954ac4f 100644 (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;
index e4e1945225b7533aa200aee89a86ec93f004ca09..b52e2cd814053c5964f9a68b99713b869a61114a 100644 (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;
 
index ac90d0a2450923af05b73347c40e38900c842af0..5da74d5e9fa8acf270d4666a6ee1425a1ef1f757 100644 (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 */