Commit 594e5dfb authored by Daniel Veillard's avatar Daniel Veillard

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)
parent d44b9364
......@@ -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) {
......
......@@ -698,7 +698,6 @@ xmlDictFree(xmlDictPtr dict) {
inside_dict = 0;
iter = next;
}
inside_dict = 0;
}
xmlFree(dict->dict);
}
......
......@@ -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)
......
......@@ -320,7 +320,6 @@ xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f) {
inside_table = 0;
iter = next;
}
inside_table = 0;
}
xmlFree(table->table);
}
......
......@@ -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;
......
......@@ -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,
......
......@@ -2416,6 +2416,7 @@ libxml_prev(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
res = (xmlNodePtr) attr->prev;
}
break;
case XML_NAMESPACE_DECL:
res = NULL;
break;
......
......@@ -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);
......
......@@ -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
......
......@@ -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++;
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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,
......
......@@ -25293,7 +25293,6 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
if (vctxt->nbAttrInfos == 0)
return (0);
nbUses = vctxt->nbAttrInfos;
/*
* Validate against the wildcard.
*/
......
......@@ -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:
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment