summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2022-09-01 02:58:00 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2022-09-01 04:31:30 +0200
commit6843fc726f7b22bb755d6d572c8f3cc0629a9c76 (patch)
tree83f5d9b6cc3326ecd097ee344ce73fdb2b05a088
parent2cac626976ac6f5883b35cf1b7b30baa5312a2ce (diff)
downloadlibxml2-6843fc726f7b22bb755d6d572c8f3cc0629a9c76.tar.gz
Remove or annotate char casts
-rw-r--r--HTMLparser.c4
-rw-r--r--parser.c2
-rw-r--r--parserInternals.c8
-rw-r--r--uri.c1
-rw-r--r--xinclude.c2
-rw-r--r--xmlstring.c1
-rw-r--r--xpath.c2
7 files changed, 11 insertions, 9 deletions
diff --git a/HTMLparser.c b/HTMLparser.c
index debbe50f..93b6661b 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -326,7 +326,7 @@ htmlNodeInfoPop(htmlParserCtxtPtr ctxt)
#define CUR_SCHAR(s, l) xmlStringCurrentChar(ctxt, s, &l)
#define COPY_BUF(l,b,i,v) \
- if (l == 1) b[i++] = (xmlChar) v; \
+ if (l == 1) b[i++] = v; \
else i += xmlCopyChar(l,&b[i],v)
/**
@@ -5924,7 +5924,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
* Handle preparsed entities and charRef
*/
if (ctxt->token != 0) {
- chr[0] = (xmlChar) ctxt->token;
+ chr[0] = ctxt->token;
htmlCheckParagraph(ctxt);
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, chr, 1);
diff --git a/parser.c b/parser.c
index e701e57f..63cc9faa 100644
--- a/parser.c
+++ b/parser.c
@@ -2169,7 +2169,7 @@ static void xmlGROW (xmlParserCtxtPtr ctxt) {
#define CUR_SCHAR(s, l) xmlStringCurrentChar(ctxt, s, &l)
#define COPY_BUF(l,b,i,v) \
- if (l == 1) b[i++] = (xmlChar) v; \
+ if (l == 1) b[i++] = v; \
else i += xmlCopyCharMultiByte(&b[i],v)
#define CUR_CONSUMED \
diff --git a/parserInternals.c b/parserInternals.c
index 43f24bfa..9dbc8f26 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -812,7 +812,7 @@ encoding_error:
*/
int
xmlCopyCharMultiByte(xmlChar *out, int val) {
- if (out == NULL) return(0);
+ if ((out == NULL) || (val < 0)) return(0);
/*
* We are supposed to handle UTF8, check it's valid
* From rfc2044: encoding of the Unicode values on UTF-8:
@@ -838,7 +838,7 @@ xmlCopyCharMultiByte(xmlChar *out, int val) {
*out++= ((val >> bits) & 0x3F) | 0x80 ;
return (out - savedout);
}
- *out = (xmlChar) val;
+ *out = val;
return 1;
}
@@ -855,12 +855,12 @@ xmlCopyCharMultiByte(xmlChar *out, int val) {
int
xmlCopyChar(int len ATTRIBUTE_UNUSED, xmlChar *out, int val) {
- if (out == NULL) return(0);
+ if ((out == NULL) || (val < 0)) return(0);
/* the len parameter is ignored */
if (val >= 0x80) {
return(xmlCopyCharMultiByte (out, val));
}
- *out = (xmlChar) val;
+ *out = val;
return 1;
}
diff --git a/uri.c b/uri.c
index cf23c3f4..e6f1c3e7 100644
--- a/uri.c
+++ b/uri.c
@@ -1657,6 +1657,7 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
c = c * 16 + (*in - 'A') + 10;
in++;
len -= 3;
+ /* Explicit sign change */
*out++ = (char) c;
} else {
*out++ = *in++;
diff --git a/xinclude.c b/xinclude.c
index d4f2314b..93d7e525 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -1714,7 +1714,7 @@ loaded:
"trying to build relative URI from %s\n", URL);
} else {
/* If the URI doesn't contain a slash, it's not relative */
- if (!xmlStrchr(curBase, (xmlChar) '/'))
+ if (!xmlStrchr(curBase, '/'))
xmlFree(curBase);
else
base = curBase;
diff --git a/xmlstring.c b/xmlstring.c
index 639ad0a0..7fbf9d07 100644
--- a/xmlstring.c
+++ b/xmlstring.c
@@ -97,6 +97,7 @@ xmlCharStrndup(const char *cur, int len) {
return(NULL);
}
for (i = 0;i < len;i++) {
+ /* Explicit sign change */
ret[i] = (xmlChar) cur[i];
if (ret[i] == 0) return(ret);
}
diff --git a/xpath.c b/xpath.c
index 9ad0f0e1..aa8df613 100644
--- a/xpath.c
+++ b/xpath.c
@@ -3098,7 +3098,7 @@ xmlXPathPopExternal (xmlXPathParserContextPtr ctxt) {
#define CUR_CHAR(l) xmlXPathCurrentChar(ctxt, &l)
#define COPY_BUF(l,b,i,v) \
- if (l == 1) b[i++] = (xmlChar) v; \
+ if (l == 1) b[i++] = v; \
else i += xmlCopyChar(l,&b[i],v)
#define NEXTL(l) ctxt->cur += l