diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-09-01 02:58:00 +0200 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-09-01 04:31:30 +0200 |
commit | 6843fc726f7b22bb755d6d572c8f3cc0629a9c76 (patch) | |
tree | 83f5d9b6cc3326ecd097ee344ce73fdb2b05a088 | |
parent | 2cac626976ac6f5883b35cf1b7b30baa5312a2ce (diff) | |
download | libxml2-6843fc726f7b22bb755d6d572c8f3cc0629a9c76.tar.gz |
Remove or annotate char casts
-rw-r--r-- | HTMLparser.c | 4 | ||||
-rw-r--r-- | parser.c | 2 | ||||
-rw-r--r-- | parserInternals.c | 8 | ||||
-rw-r--r-- | uri.c | 1 | ||||
-rw-r--r-- | xinclude.c | 2 | ||||
-rw-r--r-- | xmlstring.c | 1 | ||||
-rw-r--r-- | xpath.c | 2 |
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); @@ -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; } @@ -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++; @@ -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); } @@ -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 |