]> xenbits.xensource.com Git - libvirt.git/commitdiff
datatypes: use g_strdup instead of VIR_STRDUP
authorJán Tomko <jtomko@redhat.com>
Sun, 20 Oct 2019 11:49:46 +0000 (13:49 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 21 Oct 2019 10:51:56 +0000 (12:51 +0200)
Replace all occurrences of
  if (VIR_STRDUP(a, b) < 0)
     /* effectively dead code */
with:
  a = g_strdup(b);

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/datatypes.c

index 33c3f6be881ec005a0e8cc7cb87024f3c5a9f367..552115c7a33f137fa163b5b248aecb0627a88b34 100644 (file)
@@ -290,8 +290,7 @@ virGetDomain(virConnectPtr conn,
     if (!(ret = virObjectNew(virDomainClass)))
         goto error;
 
-    if (VIR_STRDUP(ret->name, name) < 0)
-        goto error;
+    ret->name = g_strdup(name);
 
     ret->conn = virObjectRef(conn);
     ret->id = id;
@@ -354,8 +353,7 @@ virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid)
     if (!(ret = virObjectNew(virNetworkClass)))
         goto error;
 
-    if (VIR_STRDUP(ret->name, name) < 0)
-        goto error;
+    ret->name = g_strdup(name);
 
     ret->conn = virObjectRef(conn);
     memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
@@ -477,9 +475,8 @@ virGetInterface(virConnectPtr conn, const char *name, const char *mac)
     if (!(ret = virObjectNew(virInterfaceClass)))
         goto error;
 
-    if (VIR_STRDUP(ret->name, name) < 0 ||
-        VIR_STRDUP(ret->mac, mac) < 0)
-        goto error;
+    ret->name = g_strdup(name);
+    ret->mac = g_strdup(mac);
 
     ret->conn = virObjectRef(conn);
 
@@ -542,8 +539,7 @@ virGetStoragePool(virConnectPtr conn, const char *name,
     if (!(ret = virObjectNew(virStoragePoolClass)))
         goto error;
 
-    if (VIR_STRDUP(ret->name, name) < 0)
-        goto error;
+    ret->name = g_strdup(name);
 
     ret->conn = virObjectRef(conn);
     memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
@@ -618,10 +614,9 @@ virGetStorageVol(virConnectPtr conn, const char *pool, const char *name,
     if (!(ret = virObjectNew(virStorageVolClass)))
         goto error;
 
-    if (VIR_STRDUP(ret->pool, pool) < 0 ||
-        VIR_STRDUP(ret->name, name) < 0 ||
-        VIR_STRDUP(ret->key, key) < 0)
-        goto error;
+    ret->pool = g_strdup(pool);
+    ret->name = g_strdup(name);
+    ret->key = g_strdup(key);
 
     ret->conn = virObjectRef(conn);
 
@@ -687,8 +682,7 @@ virGetNodeDevice(virConnectPtr conn, const char *name)
     if (!(ret = virObjectNew(virNodeDeviceClass)))
         goto error;
 
-    if (VIR_STRDUP(ret->name, name) < 0)
-        goto error;
+    ret->name = g_strdup(name);
 
     ret->conn = virObjectRef(conn);
     return ret;
@@ -749,8 +743,7 @@ virGetSecret(virConnectPtr conn, const unsigned char *uuid,
 
     memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
     ret->usageType = usageType;
-    if (VIR_STRDUP(ret->usageID, NULLSTR_EMPTY(usageID)) < 0)
-        goto error;
+    ret->usageID = g_strdup(NULLSTR_EMPTY(usageID));
 
     ret->conn = virObjectRef(conn);
 
@@ -859,8 +852,7 @@ virGetNWFilter(virConnectPtr conn, const char *name,
     if (!(ret = virObjectNew(virNWFilterClass)))
         goto error;
 
-    if (VIR_STRDUP(ret->name, name) < 0)
-        goto error;
+    ret->name = g_strdup(name);
 
     memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
 
@@ -924,11 +916,9 @@ virGetNWFilterBinding(virConnectPtr conn, const char *portdev,
     if (!(ret = virObjectNew(virNWFilterBindingClass)))
         goto error;
 
-    if (VIR_STRDUP(ret->portdev, portdev) < 0)
-        goto error;
+    ret->portdev = g_strdup(portdev);
 
-    if (VIR_STRDUP(ret->filtername, filtername) < 0)
-        goto error;
+    ret->filtername = g_strdup(filtername);
 
     ret->conn = virObjectRef(conn);
 
@@ -987,8 +977,7 @@ virGetDomainCheckpoint(virDomainPtr domain,
 
     if (!(ret = virObjectNew(virDomainCheckpointClass)))
         goto error;
-    if (VIR_STRDUP(ret->name, name) < 0)
-        goto error;
+    ret->name = g_strdup(name);
 
     ret->domain = virObjectRef(domain);
 
@@ -1044,8 +1033,7 @@ virGetDomainSnapshot(virDomainPtr domain, const char *name)
 
     if (!(ret = virObjectNew(virDomainSnapshotClass)))
         goto error;
-    if (VIR_STRDUP(ret->name, name) < 0)
-        goto error;
+    ret->name = g_strdup(name);
 
     ret->domain = virObjectRef(domain);
 
@@ -1192,8 +1180,7 @@ virAdmGetServer(virAdmConnectPtr conn, const char *name)
 
     if (!(ret = virObjectNew(virAdmServerClass)))
         goto error;
-    if (VIR_STRDUP(ret->name, name) < 0)
-        goto error;
+    ret->name = g_strdup(name);
 
     ret->conn = virObjectRef(conn);