[PATCH] lib: Use more of VIR_STEAL_PTR()

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

 



From: Your Name <you@xxxxxxxxxxx>

We have this very handy macro called VIR_STEAL_PTR() which steals
one pointer into the other and sets the other to NULL. The
following coccinelle patch was used to create this commit:

  @ rule1 @
  identifier a, b;
  @@

  - b = a;
    ...
  - a = NULL;
  + VIR_STEAL_PTR(b, a);

Some places were clean up afterwards to make syntax-check happy
(e.g. some curly braces were removed where the body become a one
liner).

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/domain_addr.c        |  6 ++----
 src/conf/domain_conf.c        | 21 +++++++--------------
 src/conf/secret_conf.c        |  3 +--
 src/conf/storage_conf.c       |  3 +--
 src/conf/virnetworkobj.c      |  3 +--
 src/conf/virsecretobj.c       |  3 +--
 src/libvirt-domain.c          | 12 ++++--------
 src/phyp/phyp_driver.c        |  3 +--
 src/qemu/qemu_domain.c        |  6 ++----
 src/qemu/qemu_driver.c        | 12 ++++--------
 src/qemu/qemu_migration.c     | 12 ++++--------
 src/security/virt-aa-helper.c |  3 +--
 src/storage/storage_driver.c  |  6 ++----
 src/test/test_driver.c        |  3 +--
 src/util/virdbus.c            | 18 ++++++------------
 src/util/virrotatingfile.c    |  3 +--
 src/util/virstoragefile.c     |  6 ++----
 src/vz/vz_driver.c            | 14 ++++----------
 src/vz/vz_sdk.c               |  6 ++----
 tests/networkxml2conftest.c   |  3 +--
 tools/virsh-domain.c          |  3 +--
 tools/virsh-snapshot.c        |  3 +--
 22 files changed, 50 insertions(+), 102 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 618fce44f0..04c4e6d7e1 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1757,8 +1757,7 @@ virDomainVirtioSerialAddrSetCreateFromDomain(virDomainDefPtr def)
                                    addrs) < 0)
         goto cleanup;
 
-    ret = addrs;
-    addrs = NULL;
+    VIR_STEAL_PTR(ret, addrs);
  cleanup:
     virDomainVirtioSerialAddrSetFree(addrs);
     return ret;
@@ -2095,8 +2094,7 @@ virDomainUSBAddressHubNew(size_t nports)
         goto cleanup;
     hub->nports = nports;
 
-    ret = hub;
-    hub = NULL;
+    VIR_STEAL_PTR(ret, hub);
  cleanup:
     virDomainUSBAddressHubFree(hub);
     return ret;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 22979e6c4e..9409d93c23 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7900,8 +7900,7 @@ virDomainNetIPParseXML(xmlNodePtr node)
         goto cleanup;
     }
 
-    ret = ip;
-    ip = NULL;
+    VIR_STEAL_PTR(ret, ip);
 
  cleanup:
     VIR_FREE(prefixStr);
@@ -13482,10 +13481,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
             goto error;
         }
 
-        if (!address) {
-            address = addressCompat;
-            addressCompat = NULL;
-        }
+        if (!address)
+            VIR_STEAL_PTR(address, addressCompat);
     }
 
     if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) {
@@ -13497,10 +13494,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
             goto error;
         }
 
-        if (!socketPath) {
-            socketPath = socketCompat;
-            socketCompat = NULL;
-        }
+        if (!socketPath)
+            VIR_STEAL_PTR(socketPath, socketCompat);
     }
 
     if (address && address[0] &&
@@ -14747,8 +14742,7 @@ virDomainShmemDefParseXML(virDomainXMLOptionPtr xmlopt,
         goto cleanup;
 
 
-    ret = def;
-    def = NULL;
+    VIR_STEAL_PTR(ret, def);
  cleanup:
     ctxt->node = save;
     VIR_FREE(tmp);
@@ -16187,8 +16181,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
         }
     }
 
-    ret = iommu;
-    iommu = NULL;
+    VIR_STEAL_PTR(ret, iommu);
 
  cleanup:
     ctxt->node = save;
diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index 3a5aa72563..ca6cc194a2 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -193,8 +193,7 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root)
     if (virXPathNode("./usage", ctxt) != NULL
         && virSecretDefParseUsage(ctxt, def) < 0)
         goto cleanup;
-    ret = def;
-    def = NULL;
+    VIR_STEAL_PTR(ret, def);
 
  cleanup:
     VIR_FREE(prop);
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 55db7a96f5..ba5b1f1783 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -587,8 +587,7 @@ virStoragePoolDefParseSourceString(const char *srcSpec,
                                      node) < 0)
         goto cleanup;
 
-    ret = def;
-    def = NULL;
+    VIR_STEAL_PTR(ret, def);
  cleanup:
     virStoragePoolSourceFree(def);
     xmlFreeDoc(doc);
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index e6b01388f5..3749dda751 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -602,8 +602,7 @@ virNetworkObjAssignDefLocked(virNetworkObjListPtr nets,
         obj->persistent = !(flags & VIR_NETWORK_OBJ_LIST_ADD_LIVE);
     }
 
-    ret = obj;
-    obj = NULL;
+    VIR_STEAL_PTR(ret, obj);
 
  cleanup:
     virNetworkObjEndAPI(&obj);
diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index 78911c0908..c4e7b06eca 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -394,8 +394,7 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
         virObjectRef(obj);
     }
 
-    ret = obj;
-    obj = NULL;
+    VIR_STEAL_PTR(ret, obj);
 
  cleanup:
     virSecretObjEndAPI(&obj);
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 75c9014c0e..d919a44803 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -3046,9 +3046,8 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
                           VIR_MIGRATE_AUTO_CONVERGE);
 
     VIR_DEBUG("Prepare3 %p flags=0x%x", dconn, destflags);
-    cookiein = cookieout;
     cookieinlen = cookieoutlen;
-    cookieout = NULL;
+    VIR_STEAL_PTR(cookiein, cookieout);
     cookieoutlen = 0;
     if (useParams) {
         if (virTypedParamsReplaceString(&params, &nparams,
@@ -3111,9 +3110,8 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
      */
     VIR_DEBUG("Perform3 %p uri=%s", domain->conn, uri);
     VIR_FREE(cookiein);
-    cookiein = cookieout;
     cookieinlen = cookieoutlen;
-    cookieout = NULL;
+    VIR_STEAL_PTR(cookiein, cookieout);
     cookieoutlen = 0;
     /* dconnuri not relevant in non-P2P modes, so left NULL here */
     if (useParams) {
@@ -3150,9 +3148,8 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
      */
     VIR_DEBUG("Finish3 %p ret=%d", dconn, ret);
     VIR_FREE(cookiein);
-    cookiein = cookieout;
     cookieinlen = cookieoutlen;
-    cookieout = NULL;
+    VIR_STEAL_PTR(cookiein, cookieout);
     cookieoutlen = 0;
     if (useParams) {
         if (virTypedParamsGetString(params, nparams,
@@ -3227,9 +3224,8 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
     if (notify_source) {
         VIR_DEBUG("Confirm3 %p ret=%d domain=%p", domain->conn, ret, domain);
         VIR_FREE(cookiein);
-        cookiein = cookieout;
         cookieinlen = cookieoutlen;
-        cookieout = NULL;
+        VIR_STEAL_PTR(cookiein, cookieout);
         cookieoutlen = 0;
         if (useParams) {
             ret = domain->conn->driver->domainMigrateConfirm3Params
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 4acc6ce734..4ffa08ff43 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1468,8 +1468,7 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system,
         if (VIR_STRDUP(backing_device, char_ptr) < 0)
             goto cleanup;
     } else {
-        backing_device = ret;
-        ret = NULL;
+        VIR_STEAL_PTR(backing_device, ret);
     }
 
     char_ptr = strchr(backing_device, '\n');
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f42903a343..6eeabe0df1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -11645,8 +11645,7 @@ qemuDomainCreateDeviceRecursive(const char *device,
             }
             VIR_FREE(devTmp);
             VIR_FREE(target);
-            target = tmp;
-            tmp = NULL;
+            VIR_STEAL_PTR(target, tmp);
         }
 
         if (qemuDomainCreateDeviceRecursive(target, data,
@@ -12601,8 +12600,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
             }
             VIR_FREE(fileTmp);
             VIR_FREE(target);
-            target = tmp;
-            tmp = NULL;
+            VIR_STEAL_PTR(target, tmp);
         }
 
         data.target = target;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2d8e4618bd..5387150bbd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6655,11 +6655,9 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver,
         virFreeError(err);
 
         /* use the user provided XML */
-        ret = newdef;
-        newdef = NULL;
+        VIR_STEAL_PTR(ret, newdef);
     } else {
-        ret = newdef_migr;
-        newdef_migr = NULL;
+        VIR_STEAL_PTR(ret, newdef_migr);
     }
 
  cleanup:
@@ -12705,10 +12703,8 @@ qemuDomainMigratePerform(virDomainPtr dom,
         goto cleanup;
     }
 
-    if (flags & VIR_MIGRATE_PEER2PEER) {
-        dconnuri = uri;
-        uri = NULL;
-    }
+    if (flags & VIR_MIGRATE_PEER2PEER)
+        VIR_STEAL_PTR(dconnuri, uri);
 
     /* Do not output cookies in v2 protocol, since the cookie
      * length was not sufficiently large, causing failures
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 950d9cd615..6c66ff6648 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4170,9 +4170,8 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
                           VIR_MIGRATE_AUTO_CONVERGE);
 
     VIR_DEBUG("Prepare3 %p", dconn);
-    cookiein = cookieout;
     cookieinlen = cookieoutlen;
-    cookieout = NULL;
+    VIR_STEAL_PTR(cookiein, cookieout);
     cookieoutlen = 0;
     if (flags & VIR_MIGRATE_TUNNELLED) {
         if (!(st = virStreamNew(dconn, 0)))
@@ -4239,9 +4238,8 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
     VIR_DEBUG("Perform3 %p uri=%s", sconn, NULLSTR(uri));
     qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM3);
     VIR_FREE(cookiein);
-    cookiein = cookieout;
     cookieinlen = cookieoutlen;
-    cookieout = NULL;
+    VIR_STEAL_PTR(cookiein, cookieout);
     cookieoutlen = 0;
     if (flags & VIR_MIGRATE_TUNNELLED) {
         ret = qemuMigrationSrcPerformTunnel(driver, vm, st, persist_xml,
@@ -4281,9 +4279,8 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
      */
     VIR_DEBUG("Finish3 %p ret=%d", dconn, ret);
     VIR_FREE(cookiein);
-    cookiein = cookieout;
     cookieinlen = cookieoutlen;
-    cookieout = NULL;
+    VIR_STEAL_PTR(cookiein, cookieout);
     cookieoutlen = 0;
 
     if (useParams) {
@@ -4362,9 +4359,8 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver,
      */
     VIR_DEBUG("Confirm3 %p cancelled=%d vm=%p", sconn, cancelled, vm);
     VIR_FREE(cookiein);
-    cookiein = cookieout;
     cookieinlen = cookieoutlen;
-    cookieout = NULL;
+    VIR_STEAL_PTR(cookiein, cookieout);
     cookieoutlen = 0;
     ret = qemuMigrationSrcConfirmPhase(driver, vm,
                                        cookiein, cookieinlen,
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 56d7cfadf1..8e22e9978a 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -355,8 +355,7 @@ create_profile(const char *profile, const char *profile_name,
         if (!(tmp = virStringReplace(pcontent, template_end, replace_files)))
             goto clean_all;
         VIR_FREE(pcontent);
-        pcontent = tmp;
-        tmp = NULL;
+        VIR_STEAL_PTR(pcontent, tmp);
     }
 
     /* write the file */
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 4a13e90481..878a40cac5 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1936,8 +1936,7 @@ storageVolCreateXML(virStoragePoolPtr pool,
 
     VIR_INFO("Creating volume '%s' in storage pool '%s'",
              newvol->name, def->name);
-    vol = newvol;
-    newvol = NULL;
+    VIR_STEAL_PTR(vol, newvol);
     voldef = NULL;
 
  cleanup:
@@ -2130,8 +2129,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
 
     VIR_INFO("Creating volume '%s' in storage pool '%s'",
              newvol->name, def->name);
-    vol = newvol;
-    newvol = NULL;
+    VIR_STEAL_PTR(vol, newvol);
     voldef = NULL;
 
  cleanup:
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 1d81772a46..568c52aa28 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -5595,8 +5595,7 @@ testNodeDeviceCreateXML(virConnectPtr conn,
     if (VIR_STRDUP(dev->parentName, def->parent) < 0)
         goto cleanup;
 
-    ret = dev;
-    dev = NULL;
+    VIR_STEAL_PTR(ret, dev);
 
  cleanup:
     virNodeDeviceObjEndAPI(&obj);
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index 691f182387..6725e0edb0 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -762,8 +762,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter,
                 goto cleanup;
             }
             VIR_FREE(contsig);
-            iter = newiter;
-            newiter = NULL;
+            VIR_STEAL_PTR(iter, newiter);
             types = t + 1;
             nstruct = skiplen;
             narray = (size_t)va_arg(args, int);
@@ -789,8 +788,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter,
                 VIR_FREE(newiter);
                 goto cleanup;
             }
-            iter = newiter;
-            newiter = NULL;
+            VIR_STEAL_PTR(iter, newiter);
             types = vsig;
             nstruct = strlen(types);
             narray = (size_t)-1;
@@ -821,8 +819,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter,
                 goto cleanup;
             }
             VIR_FREE(contsig);
-            iter = newiter;
-            newiter = NULL;
+            VIR_STEAL_PTR(iter, newiter);
             types = t + 1;
             nstruct = skiplen - 2;
             narray = (size_t)-1;
@@ -1059,8 +1056,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
                                      nstruct, narray) < 0)
                 goto cleanup;
             VIR_FREE(contsig);
-            iter = newiter;
-            newiter = NULL;
+            VIR_STEAL_PTR(iter, newiter);
             types = t + 1;
             nstruct = skiplen;
             if (arrayref) {
@@ -1090,8 +1086,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
                 VIR_DEBUG("Push failed");
                 goto cleanup;
             }
-            iter = newiter;
-            newiter = NULL;
+            VIR_STEAL_PTR(iter, newiter);
             types = vsig;
             nstruct = strlen(types);
             narray = (size_t)-1;
@@ -1118,8 +1113,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
                                      nstruct, narray) < 0)
                 goto cleanup;
             VIR_FREE(contsig);
-            iter = newiter;
-            newiter = NULL;
+            VIR_STEAL_PTR(iter, newiter);
             types = t + 1;
             nstruct = skiplen - 2;
             narray = (size_t)-1;
diff --git a/src/util/virrotatingfile.c b/src/util/virrotatingfile.c
index d7dc3bd1ce..7a268319a6 100644
--- a/src/util/virrotatingfile.c
+++ b/src/util/virrotatingfile.c
@@ -406,8 +406,7 @@ virRotatingFileWriterRollover(virRotatingFileWriterPtr file)
             }
 
             VIR_FREE(nextpath);
-            nextpath = thispath;
-            thispath = NULL;
+            VIR_STEAL_PTR(nextpath, thispath);
         }
     }
 
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index bd4b0274df..70fe551e5f 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1233,8 +1233,7 @@ virStorageFileGetMetadataFromFD(const char *path,
          * update the metadata.*/
         meta->type = VIR_STORAGE_TYPE_DIR;
         meta->format = VIR_STORAGE_FILE_DIR;
-        ret = meta;
-        meta = NULL;
+        VIR_STEAL_PTR(ret, meta);
         goto cleanup;
     }
 
@@ -1256,8 +1255,7 @@ virStorageFileGetMetadataFromFD(const char *path,
     else if (S_ISBLK(sb.st_mode))
         meta->type = VIR_STORAGE_TYPE_BLOCK;
 
-    ret = meta;
-    meta = NULL;
+    VIR_STEAL_PTR(ret, meta);
 
  cleanup:
     virStorageSourceFree(meta);
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 7e9ef932dc..e86a788b09 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -182,12 +182,8 @@ vzDestroyDriverConnection(void)
     vzConnPtr privconn_list;
 
     virMutexLock(&vz_driver_lock);
-    driver = vz_driver;
-    vz_driver = NULL;
-
-    privconn_list = vz_conn_list;
-    vz_conn_list = NULL;
-
+    VIR_STEAL_PTR(driver, vz_driver);
+    VIR_STEAL_PTR(privconn_list, vz_conn_list);
     virMutexUnlock(&vz_driver_lock);
 
     while (privconn_list) {
@@ -3203,9 +3199,8 @@ vzDomainMigratePerformP2P(virDomainObjPtr dom,
                                 VIR_MIGRATE_PARAM_DEST_XML, dom_xml) < 0)
         goto done;
 
-    cookiein = cookieout;
     cookieinlen = cookieoutlen;
-    cookieout = NULL;
+    VIR_STEAL_PTR(cookiein, cookieout);
     cookieoutlen = 0;
     virObjectUnlock(dom);
     ret = dconn->driver->domainMigratePrepare3Params
@@ -3226,9 +3221,8 @@ vzDomainMigratePerformP2P(virDomainObjPtr dom,
     }
 
     VIR_FREE(cookiein);
-    cookiein = cookieout;
     cookieinlen = cookieoutlen;
-    cookieout = NULL;
+    VIR_STEAL_PTR(cookiein, cookieout);
     cookieoutlen = 0;
     if (vzDomainMigratePerformStep(dom, driver, params, nparams, cookiein,
                                    cookieinlen, flags) < 0) {
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 63d013deac..b9fd03c0d2 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -928,8 +928,7 @@ prlsdkParseNetAddress(char *addr)
         goto cleanup;
     ip->prefix = nbits;
 
-    ret = ip;
-    ip = NULL;
+    VIR_STEAL_PTR(ret, ip);
 
  cleanup:
     if (!ret)
@@ -4768,8 +4767,7 @@ prlsdkParseSnapshotTree(const char *treexml)
         goto cleanup;
     }
 
-    ret = snapshots;
-    snapshots = NULL;
+    VIR_STEAL_PTR(ret, snapshots);
 
  cleanup:
     virDomainSnapshotObjListFree(snapshots);
diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
index 367e30b994..c362149c29 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -51,8 +51,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr
                                  "except-interface=lo\n")))
         goto fail;
     VIR_FREE(actual);
-    actual = tmp;
-    tmp = NULL;
+    VIR_STEAL_PTR(actual, tmp);
 #endif
 
     if (virTestCompareToFile(actual, outconf) < 0)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index e63fc028b9..34f9e6b5c6 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8423,8 +8423,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
             }
 
             VIR_FREE(desc);
-            desc = desc_edited;
-            desc_edited = NULL;
+            VIR_STEAL_PTR(desc, desc_edited);
         }
 
         if (virDomainSetMetadata(dom, type, desc, NULL, NULL, flags) < 0) {
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index e3d4cda0fc..6d8e2b299b 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -1356,8 +1356,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
           virshSnapSorter);
     snaplist->nsnaps -= deleted;
 
-    ret = snaplist;
-    snaplist = NULL;
+    VIR_STEAL_PTR(ret, snaplist);
 
  cleanup:
     virshSnapshotListFree(snaplist);
-- 
2.19.2

--
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