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

[libvirt] [PATCH v2 13/37] Adapt to VIR_STRDUP in src/interface/



---
 src/interface/interface_backend_udev.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index 7daad16..65c8c31 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -227,14 +227,12 @@ 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]) {
+        if (VIR_STRDUP(names[count], udev_device_get_sysname(dev)) < 0) {
             virReportOOMError();
+            udev_device_unref(dev);
             goto err;
         }
+        udev_device_unref(dev);
 
         count++;
     }
@@ -751,8 +749,7 @@ 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) {
+    if (VIR_STRDUP(ifacedef->data.bond.target, tmp_str) < 0) {
         virReportOOMError();
         goto cleanup;
     }
@@ -839,8 +836,7 @@ udevGetIfaceDefBridge(struct udev *udev,
         goto error;
     }
 
-    ifacedef->data.bridge.delay = strdup(tmp_str);
-    if (!ifacedef->data.bridge.delay) {
+    if (VIR_STRDUP(ifacedef->data.bridge.delay, tmp_str) < 0) {
         virReportOOMError();
         goto error;
     }
@@ -938,8 +934,7 @@ udevGetIfaceDefVlan(struct udev *udev ATTRIBUTE_UNUSED,
     char *vid;
     char *vlan_parent_dev = NULL;
 
-    vlan_parent_dev = strdup(name);
-    if (!vlan_parent_dev) {
+    if (VIR_STRDUP(vlan_parent_dev, name) < 0) {
         virReportOOMError();
         goto cleanup;
     }
@@ -987,9 +982,7 @@ 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) {
+    if (VIR_STRDUP(ifacedef->name, name) < 0) {
         virReportOOMError();
         goto cleanup;
     }
@@ -1003,8 +996,7 @@ udevGetIfaceDef(struct udev *udev, const char *name)
     }
 
     /* MAC address */
-    ifacedef->mac = strdup(udev_device_get_sysattr_value(dev, "address"));
-    if (!ifacedef->mac) {
+    if (VIR_STRDUP(ifacedef->mac, udev_device_get_sysattr_value(dev, "address")) < 0) {
         virReportOOMError();
         goto cleanup;
     }
-- 
1.8.1.5


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