[libvirt] [PATCH 10/12] storage_conf: Use VIR_STRDUP instead of strdup

Osier Yang jyang at redhat.com
Wed May 22 12:05:20 UTC 2013


---
 src/conf/storage_conf.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 1f376ef..44ecb2a 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -888,11 +888,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
     if (options->flags & VIR_STORAGE_POOL_SOURCE_NAME) {
         if (ret->source.name == NULL) {
             /* source name defaults to pool name */
-            ret->source.name = strdup(ret->name);
-            if (ret->source.name == NULL) {
-                virReportOOMError();
+            if (VIR_STRDUP(ret->source.name, ret->name) < 0)
                 goto error;
-            }
         }
     }
 
@@ -1710,16 +1707,12 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
     }
 
     VIR_FREE(pool->configFile);  /* for driver reload */
-    pool->configFile = strdup(path);
-    if (pool->configFile == NULL) {
-        virReportOOMError();
+    if (VIR_STRDUP(pool->configFile, path) < 0) {
         virStoragePoolDefFree(def);
         return NULL;
     }
     VIR_FREE(pool->autostartLink); /* for driver reload */
-    pool->autostartLink = strdup(autostartLink);
-    if (pool->autostartLink == NULL) {
-        virReportOOMError();
+    if (VIR_STRDUP(pool->autostartLink, autostartLink) < 0) {
         virStoragePoolDefFree(def);
         return NULL;
     }
-- 
1.8.1.4




More information about the libvir-list mailing list