[libxml2] Chasing dead assignments reported by clang-scan
- From: Daniel Veillard <veillard src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libxml2] Chasing dead assignments reported by clang-scan
- Date: Mon, 7 Sep 2009 13:02:56 +0000 (UTC)
commit 594e5dfb48ee6fbac1b64155839063648022fc57
Author: Daniel Veillard <veillard redhat com>
Date: Mon Sep 7 14:58:47 2009 +0200
Chasing dead assignments reported by clang-scan
* SAX2.c dict.c error.c hash.c nanohttp.c parser.c python/libxml.c
relaxng.c runtest.c tree.c valid.c xinclude.c xmlregexp.c xmlsave.c
xmlschemas.c xpath.c xpointer.c: mostly removing unneded affectations,
but this led to a few real bugs and some part not yet understood
(relaxng/interleave)
SAX2.c | 1 -
dict.c | 1 -
error.c | 1 -
hash.c | 1 -
nanohttp.c | 5 +----
parser.c | 2 --
python/libxml.c | 1 +
relaxng.c | 4 ++++
runtest.c | 3 ++-
tree.c | 6 ++----
valid.c | 5 +----
xinclude.c | 1 -
xmlregexp.c | 4 +++-
xmlsave.c | 1 -
xmlschemas.c | 1 -
xpath.c | 2 --
xpointer.c | 3 +--
17 files changed, 15 insertions(+), 27 deletions(-)
---
diff --git a/SAX2.c b/SAX2.c
index 1cf186a..1ed148f 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -2566,7 +2566,6 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
ret = xmlNewDocPI(ctxt->myDoc, target, data);
if (ret == NULL) return;
- parent = ctxt->node;
if (ctxt->linenumbers) {
if (ctxt->input != NULL) {
diff --git a/dict.c b/dict.c
index 0e07e8d..3eff231 100644
--- a/dict.c
+++ b/dict.c
@@ -698,7 +698,6 @@ xmlDictFree(xmlDictPtr dict) {
inside_dict = 0;
iter = next;
}
- inside_dict = 0;
}
xmlFree(dict->dict);
}
diff --git a/error.c b/error.c
index 8556547..814e4ea 100644
--- a/error.c
+++ b/error.c
@@ -573,7 +573,6 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
if ((to->file == NULL) && (node != NULL) && (node->doc != NULL)) {
to->file = (char *) xmlStrdup(node->doc->URL);
}
- file = to->file;
}
to->line = line;
if (str1 != NULL)
diff --git a/hash.c b/hash.c
index 22f9bb4..b78bc2d 100644
--- a/hash.c
+++ b/hash.c
@@ -320,7 +320,6 @@ xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f) {
inside_table = 0;
iter = next;
}
- inside_table = 0;
}
xmlFree(table->table);
}
diff --git a/nanohttp.c b/nanohttp.c
index 9df7a97..80e79ed 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -1337,7 +1337,6 @@ xmlNanoHTTPMethodRedir(const char *URL, const char *method, const char *input,
xmlNanoHTTPCtxtPtr ctxt;
char *bp, *p;
int blen, ret;
- int head;
int nbRedirects = 0;
char *redirURL = NULL;
#ifdef DEBUG_HTTP
@@ -1499,11 +1498,9 @@ retry:
}
ctxt->state = XML_NANO_HTTP_READ;
- head = 1;
while ((p = xmlNanoHTTPReadLine(ctxt)) != NULL) {
- if (head && (*p == 0)) {
- head = 0;
+ if (*p == 0) {
ctxt->content = ctxt->inrptr;
xmlFree(p);
break;
diff --git a/parser.c b/parser.c
index 1e4164a..e415339 100644
--- a/parser.c
+++ b/parser.c
@@ -7308,7 +7308,6 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
return(NULL);
ptr++;
- cur = *ptr;
name = xmlParseStringName(ctxt, &ptr);
if (name == NULL) {
xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
@@ -7715,7 +7714,6 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) {
if (cur != '%')
return(NULL);
ptr++;
- cur = *ptr;
name = xmlParseStringName(ctxt, &ptr);
if (name == NULL) {
xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
diff --git a/python/libxml.c b/python/libxml.c
index 3f2ede7..3f01761 100644
--- a/python/libxml.c
+++ b/python/libxml.c
@@ -2416,6 +2416,7 @@ libxml_prev(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
res = (xmlNodePtr) attr->prev;
}
+ break;
case XML_NAMESPACE_DECL:
res = NULL;
break;
diff --git a/relaxng.c b/relaxng.c
index 5146d9d..0122d57 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -6517,6 +6517,10 @@ xmlRelaxNGCheckRules(xmlRelaxNGParserCtxtPtr ctxt,
if (ptype == XML_RELAXNG_GROUP) {
val = xmlRelaxNGGroupContentType(val, ret);
} else if (ptype == XML_RELAXNG_INTERLEAVE) {
+ /*
+ * TODO: scan complain that tmp is never used, seems on purpose
+ * need double-checking
+ */
tmp = xmlRelaxNGGroupContentType(val, ret);
if (tmp != XML_RELAXNG_CONTENT_ERROR)
tmp = xmlRelaxNGMaxContentType(val, ret);
diff --git a/runtest.c b/runtest.c
index 7640aad..16196ea 100644
--- a/runtest.c
+++ b/runtest.c
@@ -3120,6 +3120,7 @@ rngOneTest(const char *sch,
filename);
}
fclose(schemasOutput);
+ ret = 0;
if (result) {
if (compareFiles(temp, result)) {
fprintf(stderr, "Result for %s on %s failed\n", filename, sch);
@@ -3229,7 +3230,7 @@ rngTest(const char *filename,
globfree(&globbuf);
xmlRelaxNGFree(schemas);
- return(res);
+ return(ret);
}
#ifdef LIBXML_READER_ENABLED
diff --git a/tree.c b/tree.c
index edca54e..ffebf06 100644
--- a/tree.c
+++ b/tree.c
@@ -1421,9 +1421,9 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
node = xmlNewDocTextLen(doc, q, cur - q);
if (node == NULL) return(ret);
if (last == NULL) {
- last = ret = node;
+ ret = node;
} else {
- last = xmlAddNextSibling(last, node);
+ xmlAddNextSibling(last, node);
}
}
}
@@ -1590,8 +1590,6 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
last = xmlAddNextSibling(last, node);
}
}
-
- charval = 0;
}
} else
cur++;
diff --git a/valid.c b/valid.c
index eb39616..37b55d0 100644
--- a/valid.c
+++ b/valid.c
@@ -4052,13 +4052,10 @@ xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) {
xmlChar fn[50];
xmlChar *fullname;
-
+
fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
if (fullname == NULL)
return(NULL);
- attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name);
- if ((attrDecl == NULL) && (doc->extSubset != NULL))
- attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name);
if ((fullname != fn) && (fullname != elem->name))
xmlFree(fullname);
}
diff --git a/xinclude.c b/xinclude.c
index 7394d0c..674db9c 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -974,7 +974,6 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
if ((cur == start) && (index1 > 1)) {
content += (index1 - 1);
len -= (index1 - 1);
- index1 = 0;
} else {
len = index2;
}
diff --git a/xmlregexp.c b/xmlregexp.c
index b1f1326..fe4bd38 100644
--- a/xmlregexp.c
+++ b/xmlregexp.c
@@ -2227,7 +2227,7 @@ xmlFACompareRanges(xmlRegRangePtr range1, xmlRegRangePtr range2) {
if (((range1->neg == 0) && (range2->neg != 0)) ||
((range1->neg != 0) && (range2->neg == 0)))
ret = !ret;
- return(1);
+ return(ret);
}
/**
@@ -6309,6 +6309,7 @@ struct _xmlExpCtxt {
int size;
int nbElems;
int nb_nodes;
+ int maxNodes;
const char *expr;
const char *cur;
int nb_cons;
@@ -6338,6 +6339,7 @@ xmlExpNewCtxt(int maxNodes, xmlDictPtr dict) {
memset(ret, 0, sizeof(xmlExpCtxt));
ret->size = size;
ret->nbElems = 0;
+ ret->maxNodes = maxNodes;
ret->table = xmlMalloc(size * sizeof(xmlExpNodePtr));
if (ret->table == NULL) {
xmlFree(ret);
diff --git a/xmlsave.c b/xmlsave.c
index c2760a8..aaa5da8 100644
--- a/xmlsave.c
+++ b/xmlsave.c
@@ -976,7 +976,6 @@ xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur) {
cur->encoding = oldenc;
return(-1);
}
- switched_encoding = 1;
}
if (ctxt->options & XML_SAVE_FORMAT)
htmlDocContentDumpFormatOutput(buf, cur,
diff --git a/xmlschemas.c b/xmlschemas.c
index acc1f78..56c65e3 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -25293,7 +25293,6 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
if (vctxt->nbAttrInfos == 0)
return (0);
- nbUses = vctxt->nbAttrInfos;
/*
* Validate against the wildcard.
*/
diff --git a/xpath.c b/xpath.c
index ab130d3..5b84d22 100644
--- a/xpath.c
+++ b/xpath.c
@@ -10868,7 +10868,6 @@ xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort) {
xmlXPathCompAndExpr(ctxt);
CHECK_ERROR;
PUSH_BINARY_EXPR(XPATH_OP_OR, op1, ctxt->comp->last, 0, 0);
- op1 = ctxt->comp->nbStep;
SKIP_BLANKS;
}
if ((sort) && (ctxt->comp->steps[ctxt->comp->last].op != XPATH_OP_VALUE)) {
@@ -11981,7 +11980,6 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
* avoid a duplicate-aware merge, if the axis to be traversed is e.g.
* the descendant-or-self axis.
*/
- addNode = xmlXPathNodeSetAdd;
mergeAndClear = xmlXPathNodeSetMergeAndClear;
switch (axis) {
case AXIS_ANCESTOR:
diff --git a/xpointer.c b/xpointer.c
index 2a62abc..7a42d02 100644
--- a/xpointer.c
+++ b/xpointer.c
@@ -2631,13 +2631,12 @@ xmlXPtrGetLastChar(xmlNodePtr *node, int *indx) {
if (cur == NULL)
return(-1);
-
+
if ((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_DOCUMENT_NODE) ||
(cur->type == XML_HTML_DOCUMENT_NODE)) {
if (pos > 0) {
cur = xmlXPtrGetNthChild(cur, pos);
- pos = 0;
}
}
while (cur != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]