[libvirt] [PATCH] virDomainSnapshotDefParse: Prefer VIR_STEAL_PTR

Michal Privoznik posted 1 patch 5 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/334612eb933189cf3f4ec2a4cf1dcfbcacf9d485.1529585113.git.mprivozn@redhat.com
Test syntax-check passed
src/conf/snapshot_conf.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[libvirt] [PATCH] virDomainSnapshotDefParse: Prefer VIR_STEAL_PTR
Posted by Michal Privoznik 5 years, 9 months ago
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/snapshot_conf.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 787c3d0feb..9c537ac7d1 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -331,8 +331,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
                          "disk-only snapshot"));
         goto cleanup;
     }
-    def->file = memoryFile;
-    memoryFile = NULL;
+    VIR_STEAL_PTR(def->file, memoryFile);
 
     /* verify that memory path is absolute */
     if (def->file && def->file[0] != '/') {
@@ -372,7 +371,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
     if (!offline && virSaveCookieParse(ctxt, &def->cookie, saveCookie) < 0)
         goto cleanup;
 
-    ret = def;
+    VIR_STEAL_PTR(ret, def);
 
  cleanup:
     VIR_FREE(creation);
@@ -380,8 +379,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
     VIR_FREE(nodes);
     VIR_FREE(memorySnapshot);
     VIR_FREE(memoryFile);
-    if (ret == NULL)
-        virDomainSnapshotDefFree(def);
+    virDomainSnapshotDefFree(def);
 
     return ret;
 }
-- 
2.16.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virDomainSnapshotDefParse: Prefer VIR_STEAL_PTR
Posted by Erik Skultety 5 years, 9 months ago
On Thu, Jun 21, 2018 at 02:45:43PM +0200, Michal Privoznik wrote:
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
Trivial..

Reviewed-by: Erik Skultety <eskultet@redhat.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list