]> xenbits.xensource.com Git - libvirt.git/commitdiff
Adapt to VIR_STRDUP and VIR_STRNDUP in src/interface/*
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 3 May 2013 12:44:36 +0000 (14:44 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 9 May 2013 12:01:30 +0000 (14:01 +0200)
src/interface/interface_backend_udev.c

index beee90a369fe01463d76d0a0b5f36912770e8db1..1c47e5c21e7c86669b3ca43d1d10fa054771d02b 100644 (file)
@@ -227,14 +227,11 @@ udevListInterfacesByStatus(virConnectPtr conn,
 
         path = udev_list_entry_get_name(dev_entry);
         dev = udev_device_new_from_syspath(udev, path);
-        names[count] = strdup(udev_device_get_sysname(dev));
-        udev_device_unref(dev);
-
-        /* If strdup() failed, we are out of memory */
-        if (!names[count]) {
-            virReportOOMError();
+        if (VIR_STRDUP(names[count], udev_device_get_sysname(dev)) < 0) {
+            udev_device_unref(dev);
             goto err;
         }
+        udev_device_unref(dev);
 
         count++;
     }
@@ -713,11 +710,8 @@ udevGetIfaceDefBond(struct udev *udev,
                 _("Could not retrieve 'bonding/arp_ip_target' for '%s'"), name);
         goto cleanup;
     }
-    ifacedef->data.bond.target = strdup(tmp_str);
-    if (!ifacedef->data.bond.target) {
-        virReportOOMError();
+    if (VIR_STRDUP(ifacedef->data.bond.target, tmp_str) < 0)
         goto cleanup;
-    }
 
     /* Slaves of the bond */
     /* Get each slave in the bond */
@@ -801,11 +795,8 @@ udevGetIfaceDefBridge(struct udev *udev,
         goto error;
     }
 
-    ifacedef->data.bridge.delay = strdup(tmp_str);
-    if (!ifacedef->data.bridge.delay) {
-        virReportOOMError();
+    if (VIR_STRDUP(ifacedef->data.bridge.delay, tmp_str) < 0)
         goto error;
-    }
 
     /* Retrieve Spanning Tree State. Valid values = -1, 0, 1 */
     tmp_str = udev_device_get_sysattr_value(dev, "bridge/stp_state");
@@ -942,12 +933,8 @@ udevGetIfaceDef(struct udev *udev, const char *name)
 
     /* Clear our structure and set safe defaults */
     ifacedef->startmode = VIR_INTERFACE_START_UNSPECIFIED;
-    ifacedef->name = strdup(name);
-
-    if (!ifacedef->name) {
-        virReportOOMError();
+    if (VIR_STRDUP(ifacedef->name, name) < 0)
         goto cleanup;
-    }
 
     /* Lookup the device we've been asked about */
     dev = udev_device_new_from_subsystem_sysname(udev, "net", name);
@@ -958,11 +945,9 @@ udevGetIfaceDef(struct udev *udev, const char *name)
     }
 
     /* MAC address */
-    ifacedef->mac = strdup(udev_device_get_sysattr_value(dev, "address"));
-    if (!ifacedef->mac) {
-        virReportOOMError();
+    if (VIR_STRDUP(ifacedef->mac,
+                   udev_device_get_sysattr_value(dev, "address")) < 0)
         goto cleanup;
-    }
 
     /* MTU */
     mtu_str = udev_device_get_sysattr_value(dev, "mtu");