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)
diff --git a/SAX2.c b/SAX2.c
index 1cf186a..1ed148f 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -2566,7 +2566,6 @@
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 @@
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 @@
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 @@
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 @@
xmlNanoHTTPCtxtPtr ctxt;
char *bp, *p;
int blen, ret;
- int head;
int nbRedirects = 0;
char *redirURL = NULL;
#ifdef DEBUG_HTTP
@@ -1499,11 +1498,9 @@
}
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 @@
return(NULL);
ptr++;
- cur = *ptr;
name = xmlParseStringName(ctxt, &ptr);
if (name == NULL) {
xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
@@ -7715,7 +7714,6 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
if (((range1->neg == 0) && (range2->neg != 0)) ||
((range1->neg != 0) && (range2->neg == 0)))
ret = !ret;
- return(1);
+ return(ret);
}
/**
@@ -6309,6 +6309,7 @@
int size;
int nbElems;
int nb_nodes;
+ int maxNodes;
const char *expr;
const char *cur;
int nb_cons;
@@ -6338,6 +6339,7 @@
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 @@
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 @@
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 @@
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 @@
* 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 @@
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) {