[libvirt] [PATCH v3 24/34] Adapt to VIR_STRDUP and VIR_STRNDUP in src/uml/*

Michal Privoznik mprivozn at redhat.com
Fri May 3 14:53:29 UTC 2013


---
 src/uml/uml_conf.c   | 10 ++++------
 src/uml/uml_driver.c |  8 +++-----
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index a55b5b1..52b705c 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -114,8 +114,8 @@ umlConnectTapDevice(virConnectPtr conn,
         STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) ||
         strchr(net->ifname, '%')) {
         VIR_FREE(net->ifname);
-        if (!(net->ifname = strdup(VIR_NET_GENERATED_PREFIX "%d")))
-            goto no_memory;
+        if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_PREFIX "%d") < 0)
+            goto error;
         /* avoid exposing vnet%d in getXMLDesc or error outputs */
         template_ifname = true;
     }
@@ -141,8 +141,6 @@ umlConnectTapDevice(virConnectPtr conn,
 
     return 0;
 
-no_memory:
-    virReportOOMError();
 error:
     return -1;
 }
@@ -463,8 +461,8 @@ virCommandPtr umlBuildCommandLine(virConnectPtr conn,
     if (vm->def->os.cmdline) {
         char *args, *next_arg;
         char *cmdline;
-        if ((cmdline = strdup(vm->def->os.cmdline)) == NULL)
-            goto no_memory;
+        if (VIR_STRDUP(cmdline, vm->def->os.cmdline) < 0)
+            goto error;
 
         args = cmdline;
         while (*args == ' ')
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 66c00b2..c658a42 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -248,8 +248,7 @@ requery:
 
     if (res && STRPREFIX(res, "pts:")) {
         VIR_FREE(def->source.data.file.path);
-        if ((def->source.data.file.path = strdup(res + 4)) == NULL) {
-            virReportOOMError();
+        if (VIR_STRDUP(def->source.data.file.path, res + 4) < 0) {
             VIR_FREE(res);
             VIR_FREE(cmd);
             return -1;
@@ -491,7 +490,7 @@ umlStateInitialize(bool privileged,
                         "%s/log/libvirt/uml", LOCALSTATEDIR) == -1)
             goto out_of_memory;
 
-        if ((base = strdup(SYSCONFDIR "/libvirt")) == NULL)
+        if (VIR_STRDUP_QUIET(base, SYSCONFDIR "/libvirt") < 0)
             goto out_of_memory;
 
         if (virAsprintf(&uml_driver->monitorDir,
@@ -1665,8 +1664,7 @@ static char *umlDomainGetOSType(virDomainPtr dom) {
         goto cleanup;
     }
 
-    if (!(type = strdup(vm->def->os.type)))
-        virReportOOMError();
+    ignore_value(VIR_STRDUP(type, vm->def->os.type));
 
 cleanup:
     if (vm)
-- 
1.8.1.5




More information about the libvir-list mailing list