Also detect and remove unnecessary if-before-xmlXPathFreeContext.

* build-aux/find-unnecessary-if-before-free: Update regexp.
* src/openvz_conf.c: Remove unnecessary "if (P)"-before xmlXPathFreeContext.
* src/qemu_conf.c: Likewise.
* src/virsh.c: Likewise.
* src/xm_internal.c: Likewise.
* src/xml.c: Likewise.
* tests/xmlrpctest.c: Likewise.
This commit is contained in:
Jim Meyering 2008-01-29 18:23:43 +00:00
parent 1be2c8c814
commit 2367caa327
8 changed files with 23 additions and 25 deletions

View File

@ -1,5 +1,14 @@
Tue Jan 29 18:39:25 CET 2008 Jim Meyering <meyering@redhat.com>
Also detect and remove unnecessary if-before-xmlXPathFreeContext.
* build-aux/find-unnecessary-if-before-free: Update regexp.
* src/virsh.c: Remove unnecessary "if (P)"-before xmlXPathFreeContext.
* src/openvz_conf.c: Likewise.
* src/qemu_conf.c: Likewise.
* src/xm_internal.c: Likewise.
* src/xml.c: Likewise.
* tests/xmlrpctest.c: Likewise.
Enable two more tests.
* Makefile.cfg (local-checks-to-skip)
[sc_cast_of_x_alloc_return_value, sc_cast_of_argument_to_free]: Enable.

View File

@ -22,7 +22,7 @@ use warnings;
{
if ($line =~
/\b(if\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)
\s+(?:sexpr_)?free\s*\(\s*\2\s*\))/sx)
\s+(?:xmlXPathFreeContext|(?:sexpr_)?free)\s*\(\s*\2\s*\))/sx)
{
print "$file: $1\n";
$found_match = 1;
@ -37,6 +37,6 @@ my $foo = <<'EOF';
# The above is to *find* them.
# This adjusts them, removing the unnecessary "if (p)" part.
git ls-files -z |xargs -0 \
perl -0x3b -pi -e 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)\s+((?:sexpr_)?free\s*\(\s*\1\s*\))/$2/s'
git ls-files -z --exclude=find-unnecessary-if-before-free |xargs -0 \
perl -0x3b -pi -e 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)\s+((?:xmlXPathFreeContext|(?:sexpr_)?free)\s*\(\s*\1\s*\))/$2/s'
EOF

View File

@ -497,7 +497,6 @@ static struct openvz_vm_def
free(prop);
if (obj)
xmlXPathFreeObject(obj);
if (ctxt)
xmlXPathFreeContext(ctxt);
openvzFreeVMDef(def);

View File

@ -1382,7 +1382,6 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
free(prop);
if (obj)
xmlXPathFreeObject(obj);
if (ctxt)
xmlXPathFreeContext(ctxt);
qemudFreeVMDef(def);
return NULL;
@ -2392,7 +2391,6 @@ static struct qemud_network_def *qemudParseNetworkXML(virConnectPtr conn,
xmlXPathFreeObject(obj);
if (tmp)
xmlXPathFreeObject(tmp);
if (ctxt)
xmlXPathFreeContext(ctxt);
qemudFreeNetworkDef(def);
return NULL;

View File

@ -504,7 +504,6 @@ cmdConsole(vshControl * ctl, vshCmd * cmd)
xmlXPathFreeObject(obj);
cleanup:
if (ctxt)
xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);
@ -2932,7 +2931,6 @@ cmdVNCDisplay(vshControl * ctl, vshCmd * cmd)
cleanup:
if (obj)
xmlXPathFreeObject(obj);
if (ctxt)
xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);
@ -2995,7 +2993,6 @@ cmdTTYConsole(vshControl * ctl, vshCmd * cmd)
cleanup:
if (obj)
xmlXPathFreeObject(obj);
if (ctxt)
xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);
@ -3337,7 +3334,6 @@ cmdDetachInterface(vshControl * ctl, vshCmd * cmd)
virDomainFree(dom);
if (obj)
xmlXPathFreeObject(obj);
if (ctxt)
xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);
@ -3611,7 +3607,6 @@ cmdDetachDisk(vshControl * ctl, vshCmd * cmd)
cleanup:
if (obj)
xmlXPathFreeObject(obj);
if (ctxt)
xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);

View File

@ -2273,7 +2273,6 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
xmlFree(prop);
if (obj != NULL)
xmlXPathFreeObject(obj);
if (ctxt != NULL)
xmlXPathFreeContext(ctxt);
if (doc != NULL)
xmlFreeDoc(doc);

View File

@ -1795,7 +1795,6 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
free(nam);
if (name != NULL)
*name = NULL;
if (ctxt != NULL)
xmlXPathFreeContext(ctxt);
if (xml != NULL)
xmlFreeDoc(xml);

View File

@ -121,7 +121,6 @@ checkRequestValue(const char *xmlstr, const char *xpath, int type, void *expecte
error:
if (obj)
xmlXPathFreeObject(obj);
if (ctxt)
xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);