* 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.
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.
{
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;
# 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
free(prop);
if (obj)
xmlXPathFreeObject(obj);
- if (ctxt)
- xmlXPathFreeContext(ctxt);
+ xmlXPathFreeContext(ctxt);
openvzFreeVMDef(def);
return NULL;
free(prop);
if (obj)
xmlXPathFreeObject(obj);
- if (ctxt)
- xmlXPathFreeContext(ctxt);
+ xmlXPathFreeContext(ctxt);
qemudFreeVMDef(def);
return NULL;
}
xmlXPathFreeObject(obj);
if (tmp)
xmlXPathFreeObject(tmp);
- if (ctxt)
- xmlXPathFreeContext(ctxt);
+ xmlXPathFreeContext(ctxt);
qemudFreeNetworkDef(def);
return NULL;
}
xmlXPathFreeObject(obj);
cleanup:
- if (ctxt)
- xmlXPathFreeContext(ctxt);
+ xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);
virDomainFree(dom);
cleanup:
if (obj)
xmlXPathFreeObject(obj);
- if (ctxt)
- xmlXPathFreeContext(ctxt);
+ xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);
virDomainFree(dom);
cleanup:
if (obj)
xmlXPathFreeObject(obj);
- if (ctxt)
- xmlXPathFreeContext(ctxt);
+ xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);
virDomainFree(dom);
virDomainFree(dom);
if (obj)
xmlXPathFreeObject(obj);
- if (ctxt)
- xmlXPathFreeContext(ctxt);
+ xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);
if (xml_buf)
cleanup:
if (obj)
xmlXPathFreeObject(obj);
- if (ctxt)
- xmlXPathFreeContext(ctxt);
+ xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);
if (xml_buf)
xmlFree(prop);
if (obj != NULL)
xmlXPathFreeObject(obj);
- if (ctxt != NULL)
- xmlXPathFreeContext(ctxt);
+ xmlXPathFreeContext(ctxt);
if (doc != NULL)
xmlFreeDoc(doc);
return (NULL);
free(nam);
if (name != NULL)
*name = NULL;
- if (ctxt != NULL)
- xmlXPathFreeContext(ctxt);
+ xmlXPathFreeContext(ctxt);
if (xml != NULL)
xmlFreeDoc(xml);
if (pctxt != NULL)
error:
if (obj)
xmlXPathFreeObject(obj);
- if (ctxt)
- xmlXPathFreeContext(ctxt);
+ xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);
return ret;