Commit 13cee4e3 authored by Daniel Veillard's avatar Daniel Veillard

Fix a bunch of scan 'dead increments' and cleanup

* HTMLparser.c c14n.c debugXML.c entities.c nanohttp.c parser.c
  testC14N.c uri.c xmlcatalog.c xmllint.c xmlregexp.c xpath.c:
  fix unused variables, or unneeded increments as well as a couple
  of space issues
* runtest.c: check for NULL before calling unlink()
parent 141ebfa0
......@@ -2560,7 +2560,7 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
NEXT;
}
}
*out++ = 0;
*out = 0;
return(buffer);
}
......
......@@ -2226,7 +2226,7 @@ xmlC11NNormalizeString(const xmlChar * input,
}
cur++;
}
*out++ = 0;
*out = 0;
return (buffer);
}
#endif /* LIBXML_OUTPUT_ENABLED */
......
......@@ -2803,7 +2803,6 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
{
char prompt[500] = "/ > ";
char *cmdline = NULL, *cur;
int nbargs;
char command[100];
char arg[400];
int i;
......@@ -2855,7 +2854,6 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
* Parse the command itself
*/
cur = cmdline;
nbargs = 0;
while ((*cur == ' ') || (*cur == '\t'))
cur++;
i = 0;
......@@ -2868,7 +2866,6 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
command[i] = 0;
if (i == 0)
continue;
nbargs++;
/*
* Parse the argument
......@@ -2882,8 +2879,6 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
arg[i++] = *cur++;
}
arg[i] = 0;
if (i != 0)
nbargs++;
/*
* start interpreting the command
......
......@@ -690,7 +690,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
}
cur++;
}
*out++ = 0;
*out = 0;
return(buffer);
}
......@@ -772,7 +772,7 @@ xmlEncodeSpecialChars(xmlDocPtr doc ATTRIBUTE_UNUSED, const xmlChar *input) {
}
cur++;
}
*out++ = 0;
*out = 0;
return(buffer);
}
......
......@@ -150,6 +150,7 @@ typedef struct xmlNanoHTTPCtxt {
int inlen; /* len of the input buffer */
int last; /* return code for last operation */
int returnValue; /* the protocol return value */
int version; /* the protocol version */
int ContentLength; /* specified content length from HTTP header */
char *contentType; /* the MIME type for the input */
char *location; /* the new URL in case of redirect */
......@@ -722,6 +723,7 @@ xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr ctxt, const char *line) {
}
if ((*cur != 0) && (*cur != ' ') && (*cur != '\t')) return;
ctxt->returnValue = ret;
ctxt->version = version;
} else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"Content-Type:", 13)) {
const xmlChar *charset, *last, *mime;
cur += 13;
......
......@@ -2616,7 +2616,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
else
c = 0;
}
buffer[nbchars++] = 0;
buffer[nbchars] = 0;
return(buffer);
mem_error:
......
......@@ -1704,9 +1704,11 @@ saxParseTest(const char *filename, const char *result,
if (compareFiles(temp, result)) {
fprintf(stderr, "Got a difference for %s\n", filename);
ret = 1;
} else
unlink(temp);
free(temp);
}
if (temp != NULL) {
unlink(temp);
free(temp);
}
/* switch back to structured error handling */
xmlSetGenericErrorFunc(NULL, NULL);
......@@ -1779,8 +1781,10 @@ oldParseTest(const char *filename, const char *result,
}
xmlFreeDoc(doc);
unlink(temp);
free(temp);
if (temp != NULL) {
unlink(temp);
free(temp);
}
return(res);
}
......@@ -1980,8 +1984,10 @@ noentParseTest(const char *filename, const char *result,
}
xmlFreeDoc(doc);
unlink(temp);
free(temp);
if (temp != NULL) {
unlink(temp);
free(temp);
}
return(res);
}
......@@ -2120,8 +2126,10 @@ streamProcessTest(const char *filename, const char *result, const char *err,
testErrorHandler(NULL, "Relax-NG schema %s failed to compile\n",
rng);
fclose(t);
unlink(temp);
free(temp);
if (temp != NULL) {
unlink(temp);
free(temp);
}
return(0);
}
}
......@@ -2147,8 +2155,10 @@ streamProcessTest(const char *filename, const char *result, const char *err,
if (t != NULL) {
fclose(t);
ret = compareFiles(temp, result);
unlink(temp);
free(temp);
if (temp != NULL) {
unlink(temp);
free(temp);
}
if (ret) {
fprintf(stderr, "Result for %s failed\n", filename);
return(-1);
......@@ -2357,8 +2367,10 @@ xpathCommonTest(const char *filename, const char *result,
}
}
unlink(temp);
free(temp);
if (temp != NULL) {
unlink(temp);
free(temp);
}
return(ret);
}
......@@ -2527,8 +2539,10 @@ xmlidDocTest(const char *filename,
}
}
unlink(temp);
free(temp);
if (temp != NULL) {
unlink(temp);
free(temp);
}
xmlFreeDoc(xpathDocument);
if (err != NULL) {
......@@ -2614,8 +2628,10 @@ uriCommonTest(const char *filename,
if (f == NULL) {
fprintf(stderr, "failed to open input file %s\n", filename);
fclose(o);
unlink(temp);
free(temp);
if (temp != NULL) {
unlink(temp);
free(temp);
}
return(-1);
}
......@@ -2658,8 +2674,10 @@ uriCommonTest(const char *filename,
}
}
unlink(temp);
free(temp);
if (temp != NULL) {
unlink(temp);
free(temp);
}
return(res);
}
......@@ -2933,8 +2951,10 @@ schemasOneTest(const char *sch,
ret = 1;
}
}
unlink(temp);
free(temp);
if (temp != NULL) {
unlink(temp);
free(temp);
}
if ((validResult != 0) && (err != NULL)) {
if (compareFileMem(err, testErrors, testErrorsSize)) {
......@@ -3106,8 +3126,10 @@ rngOneTest(const char *sch,
ret = 1;
}
}
unlink(temp);
free(temp);
if (temp != NULL) {
unlink(temp);
free(temp);
}
if (err != NULL) {
if (compareFileMem(err, testErrors, testErrorsSize)) {
......@@ -3464,7 +3486,7 @@ patternTest(const char *filename,
namespaces[j++] = ns->prefix;
}
namespaces[j++] = NULL;
namespaces[j++] = NULL;
namespaces[j] = NULL;
patternc = xmlPatterncompile((const xmlChar *) str, doc->dict,
0, &namespaces[0]);
......@@ -3512,8 +3534,10 @@ patternTest(const char *filename,
fprintf(stderr, "Result for %s failed\n", filename);
ret = 1;
}
unlink(temp);
free(temp);
if (temp != NULL) {
unlink(temp);
free(temp);
}
return(ret);
}
#endif /* READER */
......@@ -3643,7 +3667,6 @@ parse_list(xmlChar *str) {
if((str[0] == '\'') && (str[len - 1] == '\'')) {
str[len - 1] = '\0';
str++;
len -= 2;
}
/*
* allocate an translation buffer.
......
......@@ -170,7 +170,7 @@ int main(int argc, char **argv) {
*/
xmlCleanupParser();
xmlMemoryDump();
return((ret >= 0) ? 0 : 1);
}
......@@ -180,7 +180,7 @@ int main(int argc, char **argv) {
#define growBufferReentrant() { \
buffer_size *= 2; \
buffer = (xmlChar **) \
xmlRealloc(buffer, buffer_size * sizeof(xmlChar*)); \
xmlRealloc(buffer, buffer_size * sizeof(xmlChar*)); \
if (buffer == NULL) { \
perror("realloc failed"); \
return(NULL); \
......@@ -202,7 +202,6 @@ parse_list(xmlChar *str) {
if((str[0] == '\'') && (str[len - 1] == '\'')) {
str[len - 1] = '\0';
str++;
len -= 2;
}
/*
* allocate an translation buffer.
......@@ -214,7 +213,7 @@ parse_list(xmlChar *str) {
return(NULL);
}
out = buffer;
while(*str != '\0') {
if (out - buffer > buffer_size - 10) {
int indx = out - buffer;
......
......@@ -1373,7 +1373,7 @@ xmlSaveUri(xmlURIPtr uri) {
}
ret = temp;
}
ret[len++] = 0;
ret[len] = 0;
return(ret);
}
......
......@@ -124,7 +124,6 @@ static void usershell(void) {
free(cmdline);
continue;
}
nbargs++;
/*
* Parse the argument string
......@@ -138,8 +137,6 @@ static void usershell(void) {
arg[i++] = *cur++;
}
arg[i] = 0;
if (i != 0)
nbargs++;
/*
* Parse the arguments
......
......@@ -1990,7 +1990,7 @@ static void walkDoc(xmlDocPtr doc) {
namespaces[i++] = ns->prefix;
}
namespaces[i++] = NULL;
namespaces[i++] = NULL;
namespaces[i] = NULL;
if (pattern != NULL) {
patternc = xmlPatterncompile((const xmlChar *) pattern, doc->dict,
......
......@@ -6923,7 +6923,7 @@ tail:
return(0);
if (nb >= len)
return(-2);
list[nb++] = exp->exp_str;
list[nb] = exp->exp_str;
return(1);
case XML_EXP_COUNT:
exp = exp->exp_left;
......@@ -6978,7 +6978,7 @@ tail:
return(0);
if (nb >= len)
return(-2);
list[nb++] = exp->exp_str;
list[nb] = exp->exp_str;
return(1);
case XML_EXP_COUNT:
exp = exp->exp_left;
......
......@@ -14505,7 +14505,7 @@ xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
namespaces[i++] = ns->prefix;
}
namespaces[i++] = NULL;
namespaces[i++] = NULL;
namespaces[i] = 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