[PATCH 2/5] storage: Add error path for virStorageBackendCreateQemuImgCmdFromVol

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

 



Rather than inline the various free's and return NULL, just create
an error label.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_util.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 50db358dc4..561899a3d0 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -1261,19 +1261,13 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn,
     if (info.format == VIR_STORAGE_FILE_RAW &&
         vol->target.encryption != NULL &&
         vol->target.encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
-        if (storageBackendCreateQemuImgSecretObject(cmd, vol, &info) < 0) {
-            VIR_FREE(info.secretAlias);
-            virCommandFree(cmd);
-            return NULL;
-        }
+        if (storageBackendCreateQemuImgSecretObject(cmd, vol, &info) < 0)
+            goto error;
         enc = &vol->target.encryption->encinfo;
     }
 
-    if (storageBackendCreateQemuImgSetOptions(cmd, imgformat, enc, info) < 0) {
-        VIR_FREE(info.secretAlias);
-        virCommandFree(cmd);
-        return NULL;
-    }
+    if (storageBackendCreateQemuImgSetOptions(cmd, imgformat, enc, info) < 0)
+        goto error;
     VIR_FREE(info.secretAlias);
 
     if (info.inputPath)
@@ -1283,6 +1277,11 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn,
         virCommandAddArgFormat(cmd, "%lluK", info.size_arg);
 
     return cmd;
+
+ error:
+    VIR_FREE(info.secretAlias);
+    virCommandFree(cmd);
+    return NULL;
 }
 
 
-- 
2.13.6

--
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]
  Powered by Linux