[libvirt] [PATCH 15/75] node_device: Drop virAsprintf() and virAsprintfQuiet() retval checking

Michal Privoznik mprivozn at redhat.com
Tue Oct 22 13:57:19 UTC 2019


These functions can't fail really. Drop checking of their retval
then.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/node_device/node_device_driver.c |  3 +--
 src/node_device/node_device_hal.c    |  7 ++-----
 src/node_device/node_device_udev.c   | 11 +++--------
 3 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 7ef55f45e9..53373140be 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -113,8 +113,7 @@ nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def)
 
     VIR_FREE(def->driver);
 
-    if (virAsprintf(&driver_link, "%s/driver", def->sysfs_path) < 0)
-        goto cleanup;
+    virAsprintf(&driver_link, "%s/driver", def->sysfs_path);
 
     /* Some devices don't have an explicit driver, so just return
        without a name */
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 688a0e0f06..a6042e6bfc 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -614,16 +614,13 @@ nodeStateInitialize(bool privileged G_GNUC_UNUSED,
     nodeDeviceLock();
 
     if (privileged) {
-        if (virAsprintf(&driver->stateDir,
-                        "%s/libvirt/nodedev", RUNSTATEDIR) < 0)
-            goto failure;
+        virAsprintf(&driver->stateDir, "%s/libvirt/nodedev", RUNSTATEDIR);
     } else {
         g_autofree char *rundir = NULL;
 
         if (!(rundir = virGetUserRuntimeDirectory()))
             goto failure;
-        if (virAsprintf(&driver->stateDir, "%s/nodedev/run", rundir) < 0)
-            goto failure;
+        virAsprintf(&driver->stateDir, "%s/nodedev/run", rundir);
     }
 
     if (virFileMakePathWithMode(driver->stateDir, S_IRWXU) < 0) {
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 525e71f80c..92d7048ece 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1028,9 +1028,7 @@ udevProcessMediatedDevice(struct udev_device *dev,
      * it by waiting for the attributes to become available.
      */
 
-    if (virAsprintf(&linkpath, "%s/mdev_type",
-                    udev_device_get_syspath(dev)) < 0)
-        goto cleanup;
+    virAsprintf(&linkpath, "%s/mdev_type", udev_device_get_syspath(dev));
 
     if (virFileWaitForExists(linkpath, 1, 100) < 0) {
         virReportSystemError(errno,
@@ -1812,16 +1810,13 @@ nodeStateInitialize(bool privileged,
     driver->privileged = privileged;
 
     if (privileged) {
-        if (virAsprintf(&driver->stateDir,
-                        "%s/libvirt/nodedev", RUNSTATEDIR) < 0)
-            goto cleanup;
+        virAsprintf(&driver->stateDir, "%s/libvirt/nodedev", RUNSTATEDIR);
     } else {
         g_autofree char *rundir = NULL;
 
         if (!(rundir = virGetUserRuntimeDirectory()))
             goto cleanup;
-        if (virAsprintf(&driver->stateDir, "%s/nodedev/run", rundir) < 0)
-            goto cleanup;
+        virAsprintf(&driver->stateDir, "%s/nodedev/run", rundir);
     }
 
     if (virFileMakePathWithMode(driver->stateDir, S_IRWXU) < 0) {
-- 
2.21.0




More information about the libvir-list mailing list