[PATCH 24/75] test: Drop virAsprintf() and virAsprintfQuiet() retval checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/test/test_driver.c | 35 +++++++++++++----------------------
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index e00a65d8bb..96607c04eb 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -640,8 +640,7 @@ testDomainGenerateIfname(virDomainDefPtr domdef)
         virDomainNetDefPtr net = NULL;
         char *ifname;
 
-        if (virAsprintf(&ifname, "testnet%d", ifctr) < 0)
-            return NULL;
+        virAsprintf(&ifname, "testnet%d", ifctr);
 
         /* Generate network interface names */
         if (!(net = virDomainNetFindByName(domdef, ifname)))
@@ -1076,8 +1075,7 @@ testOpenVolumesForPool(const char *file,
     g_autoptr(virStorageVolDef) volDef = NULL;
 
     /* Find storage volumes */
-    if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0)
-        return -1;
+    virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx);
 
     num = virXPathNodeSet(vol_xpath, ctxt, &nodes);
     if (num < 0)
@@ -1093,9 +1091,8 @@ testOpenVolumesForPool(const char *file,
             return -1;
 
         if (!volDef->target.path) {
-            if (virAsprintf(&volDef->target.path, "%s/%s",
-                            def->target.path, volDef->name) < 0)
-                return -1;
+            virAsprintf(&volDef->target.path, "%s/%s", def->target.path,
+                        volDef->name);
         }
 
         if (!volDef->key)
@@ -2046,7 +2043,7 @@ testDomainGetHostname(virDomainPtr domain,
     if (virDomainObjCheckActive(vm) < 0)
         goto cleanup;
 
-    ignore_value(virAsprintf(&ret, "%shost", domain->name));
+    virAsprintf(&ret, "%shost", domain->name);
 
  cleanup:
     virDomainObjEndAPI(&vm);
@@ -4735,8 +4732,7 @@ testDomainGetFSInfo(virDomainPtr dom,
             info_ret[0]->mountpoint = g_strdup("/");
             info_ret[0]->fstype = g_strdup("ext4");
             info_ret[0]->devAlias[0] = g_strdup(name);
-            if (virAsprintf(&info_ret[0]->name, "%s1", name) < 0)
-                goto cleanup;
+            virAsprintf(&info_ret[0]->name, "%s1", name);
 
             if (VIR_ALLOC(info_ret[1]) < 0 ||
                 VIR_ALLOC(info_ret[1]->devAlias) < 0)
@@ -4745,8 +4741,7 @@ testDomainGetFSInfo(virDomainPtr dom,
             info_ret[1]->mountpoint = g_strdup("/boot");
             info_ret[1]->fstype = g_strdup("ext4");
             info_ret[1]->devAlias[0] = g_strdup(name);
-            if (virAsprintf(&info_ret[1]->name, "%s2", name) < 0)
-                goto cleanup;
+            virAsprintf(&info_ret[1]->name, "%s2", name);
 
             info_ret[0]->ndevAlias = info_ret[1]->ndevAlias = 1;
 
@@ -5116,8 +5111,7 @@ testDomainInterfaceAddresses(virDomainPtr dom,
         } else {
             iface->addrs[0].type = VIR_IP_ADDR_TYPE_IPV4;
             iface->addrs[0].prefix = 24;
-            if (virAsprintf(&iface->addrs[0].addr, "192.168.0.%zu", 1 + i) < 0)
-                goto cleanup;
+            virAsprintf(&iface->addrs[0].addr, "192.168.0.%zu", 1 + i);
 
         }
 
@@ -6370,8 +6364,7 @@ testConnectFindStoragePoolSources(virConnectPtr conn G_GNUC_UNUSED,
             return NULL;
         }
 
-        ignore_value(virAsprintf(&ret, defaultPoolSourcesNetFSXML,
-                                 source->hosts[0].name));
+        virAsprintf(&ret, defaultPoolSourcesNetFSXML, source->hosts[0].name);
         return ret;
 
     default:
@@ -7014,9 +7007,8 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
         goto cleanup;
     }
 
-    if (virAsprintf(&privvol->target.path, "%s/%s",
-                    def->target.path, privvol->name) < 0)
-        goto cleanup;
+    virAsprintf(&privvol->target.path, "%s/%s", def->target.path,
+                privvol->name);
 
     privvol->key = g_strdup(privvol->target.path);
     if (virStoragePoolObjAddVol(obj, privvol) < 0)
@@ -7082,9 +7074,8 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
     }
     def->available = (def->capacity - def->allocation);
 
-    if (virAsprintf(&privvol->target.path, "%s/%s",
-                    def->target.path, privvol->name) < 0)
-        goto cleanup;
+    virAsprintf(&privvol->target.path, "%s/%s", def->target.path,
+                privvol->name);
 
     privvol->key = g_strdup(privvol->target.path);
     if (virStoragePoolObjAddVol(obj, privvol) < 0)
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux