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,8 +497,7 @@ static struct openvz_vm_def
free(prop);
if (obj)
xmlXPathFreeObject(obj);
if (ctxt)
xmlXPathFreeContext(ctxt);
xmlXPathFreeContext(ctxt);
openvzFreeVMDef(def);
return NULL;

View File

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

View File

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

View File

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

View File

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

View File

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