[PATCH v2 17/37] Adapt to VIR_STRDUP in src/phyp/*

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

 



---
 src/phyp/phyp_driver.c | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 85eb650..1cb92d2 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -954,9 +954,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
     }
 
     if (conn->uri->user != NULL) {
-        username = strdup(conn->uri->user);
-
-        if (username == NULL) {
+        if (VIR_STRDUP(username, conn->uri->user) < 0) {
             virReportOOMError();
             goto err;
         }
@@ -1141,12 +1139,10 @@ phypConnectOpen(virConnectPtr conn,
 
     if (conn->uri->path) {
         /* need to shift one byte in order to remove the first "/" of URI component */
-        if (conn->uri->path[0] == '/')
-            managed_system = strdup(conn->uri->path + 1);
-        else
-            managed_system = strdup(conn->uri->path);
-
-        if (!managed_system) {
+        if ((conn->uri->path[0] == '/' &&
+             VIR_STRDUP(managed_system, conn->uri->path + 1) < 0) ||
+            (conn->uri->path[0] != '/' &&
+             VIR_STRDUP(managed_system, conn->uri->path) < 0)) {
             virReportOOMError();
             goto failure;
         }
@@ -1498,9 +1494,7 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system,
         else
             goto cleanup;
 
-        backing_device = strdup(char_ptr);
-
-        if (backing_device == NULL) {
+        if (VIR_STRDUP(backing_device, char_ptr) < 0) {
             virReportOOMError();
             goto cleanup;
         }
@@ -1731,9 +1725,7 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml)
         goto cleanup;
     }
 
-    def->os.type = strdup("aix");
-
-    if (def->os.type == NULL) {
+    if (VIR_STRDUP(def->os.type, "aix") < 0) {
         virReportOOMError();
         goto cleanup;
     }
@@ -2281,9 +2273,7 @@ phypStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
         goto cleanup;
     }
 
-    voldef.key = strdup(vol->key);
-
-    if (voldef.key == NULL) {
+    if (VIR_STRDUP(voldef.key, vol->key) < 0) {
         virReportOOMError();
         goto cleanup;
     }
@@ -2399,7 +2389,7 @@ phypStoragePoolListVolumes(virStoragePoolPtr pool, char **const volumes,
 
             if (char_ptr) {
                 *char_ptr = '\0';
-                if ((volumes[got++] = strdup(volumes_list)) == NULL) {
+                if (VIR_STRDUP(volumes[got++], volumes_list) < 0) {
                     virReportOOMError();
                     goto cleanup;
                 }
@@ -2600,7 +2590,7 @@ phypConnectListStoragePools(virConnectPtr conn, char **const pools, int npools)
 
             if (char_ptr) {
                 *char_ptr = '\0';
-                if ((pools[got++] = strdup(storage_pools)) == NULL) {
+                if (VIR_STRDUP(pools[got++], storage_pools) < 0) {
                     virReportOOMError();
                     goto cleanup;
                 }
@@ -3067,7 +3057,7 @@ phypConnectListInterfaces(virConnectPtr conn, char **const names, int nnames)
 
         if (char_ptr) {
             *char_ptr = '\0';
-            if ((names[got++] = strdup(networks)) == NULL) {
+            if (VIR_STRDUP(names[got++], networks) < 0) {
                 virReportOOMError();
                 goto cleanup;
             }
@@ -3234,7 +3224,7 @@ phypConnectListDefinedDomains(virConnectPtr conn, char **const names, int nnames
 
             if (char_ptr) {
                 *char_ptr = '\0';
-                if ((names[got++] = strdup(domains)) == NULL) {
+                if (VIR_STRDUP(names[got++], domains) < 0) {
                     virReportOOMError();
                     goto cleanup;
                 }
-- 
1.8.1.5

--
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]