]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Use virStorageSourceNew in virStorageFileMetadataNew
authorPeter Krempa <pkrempa@redhat.com>
Mon, 18 Feb 2019 12:24:37 +0000 (13:24 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 18 Feb 2019 13:00:15 +0000 (14:00 +0100)
Commit dcda2bf4c110 forgot to fix this one instance.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/util/virstoragefile.c

index 5927140a6662be95022e5180e747b2dbb99d470e..b2e308d81d9a7511810ff52d7459515c11284d1b 100644 (file)
@@ -1119,22 +1119,20 @@ static virStorageSourcePtr
 virStorageFileMetadataNew(const char *path,
                           int format)
 {
-    virStorageSourcePtr def = NULL;
+    VIR_AUTOUNREF(virStorageSourcePtr) def = NULL;
+    virStorageSourcePtr ret = NULL;
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virStorageSourceNew()))
         return NULL;
 
     def->format = format;
     def->type = VIR_STORAGE_TYPE_FILE;
 
     if (VIR_STRDUP(def->path, path) < 0)
-        goto error;
-
-    return def;
+        return NULL;
 
- error:
-    virObjectUnref(def);
-    return NULL;
+    VIR_STEAL_PTR(ret, def);
+    return ret;
 }