Eric Blake wrote:
On 03/25/2010 02:56 PM, Jim Meyering wrote:
> 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.
ACK
Thanks for the review..
I've gone ahead and fixed both violations, so I can push this right away
without breaking syntax-check, rather than having to wait for Jiri's
change to be committed. Besides, it is more appropriate to keep clean-up
style changes separate from "real" (semantics-changing) ones.
From 156133597dee6e79768c267b2fb4b5ebff5998f0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
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.
* src/conf/domain_conf.c (virDomainAssignDef): Likewise
---
cfg.mk | 1 +
src/conf/domain_conf.c | 3 +--
src/test/test_driver.c | 3 +--
3 files changed, 3 insertions(+), 4 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/conf/domain_conf.c b/src/conf/domain_conf.c
index 22e1679..5519834 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -759,8 +759,7 @@ virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
virDomainDefFree(domain->def);
domain->def = def;
} else {
- if (domain->newDef)
- virDomainDefFree(domain->newDef);
+ virDomainDefFree(domain->newDef);
domain->newDef = def;
}
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