[libvirt] [PATCH 03/10] util: storagefile: Introduce helper to free storage source perms

Peter Krempa pkrempa at redhat.com
Thu Jun 19 13:46:37 UTC 2014


It will also be reused later.
---
 src/util/virstoragefile.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 09b5d10..a23ac6a 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1451,6 +1451,17 @@ virStorageNetHostDefFree(size_t nhosts,
 }


+static void
+virStoragePermsFree(virStoragePermsPtr def)
+{
+    if (!def)
+        return;
+
+    VIR_FREE(def->label);
+    VIR_FREE(def);
+}
+
+
 virStorageNetHostDefPtr
 virStorageNetHostDefCopy(size_t nhosts,
                          virStorageNetHostDefPtr hosts)
@@ -1564,10 +1575,7 @@ virStorageSourceClear(virStorageSourcePtr def)
             virSecurityDeviceLabelDefFree(def->seclabels[i]);
         VIR_FREE(def->seclabels);
     }
-    if (def->perms) {
-        VIR_FREE(def->perms->label);
-        VIR_FREE(def->perms);
-    }
+    virStoragePermsFree(def->perms);
     VIR_FREE(def->timestamps);

     virStorageNetHostDefFree(def->nhosts, def->hosts);
-- 
1.9.3




More information about the libvir-list mailing list