[libvirt] [PATCH] tests: teach syntax-check that virDomainDefFree has free-like semantics

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

 



Eric Blake wrote:
> On 03/24/2010 08:52 AM, Jiri Denemark wrote:
...
>>  virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
> ...
>
>>          } else {
>> -            if (domain->newDef)
>> -                virDomainDefFree(domain->newDef);
>> +            virDomainDefFree(domain->newDef);
>
> And nice removal of useless-if-before-free.

Thanks for highlighting that.
Our syntax-check rule should have caught it.
With the following change, it does, along with one other:

    src/conf/domain_conf.c: if (domain->newDef)
                    virDomainDefFree(domain->newDef)
    src/test/test_driver.c: if (def)
            virDomainDefFree(def)
    maint.mk: found useless "if" before "free" above
    make: *** [sc_avoid_if_before_free] Error 1

This also fixes the one not fixed by Jiri's change.

>From 032b5a8b01ae00c00975ea32eb045dbee620331f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Thu, 25 Mar 2010 21:53:29 +0100
Subject: [PATCH] tests: teach syntax-check that virDomainDefFree has free-like semantics

* cfg.mk (useless_free_options): Add virDomainDefFree to the list
of free-like functions.
* src/test/test_driver.c (testDomainCreateXML): Remove useless-if-
before-virDomainDefFree.
---
 cfg.mk                 |    1 +
 src/test/test_driver.c |    3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 4302338..bf5eae3 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -64,6 +64,7 @@ useless_free_options =		\
   --name=VIR_FREE		\
   --name=xmlFree		\
   --name=xmlXPathFreeContext	\
+  --name=virDomainDefFree	\
   --name=xmlXPathFreeObject

 # Avoid uses of write(2).  Either switch to streams (fwrite), or use
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index f54ebae..fb5c3f6 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1328,8 +1328,7 @@ cleanup:
         virDomainObjUnlock(dom);
     if (event)
         testDomainEventQueue(privconn, event);
-    if (def)
-        virDomainDefFree(def);
+    virDomainDefFree(def);
     testDriverUnlock(privconn);
     return ret;
 }
--
1.7.0.3.448.g82eeb

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