summaryrefslogtreecommitdiff
path: root/expat
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2022-10-21 20:53:23 -0400
committerSean McBride <sean@rogue-research.com>2022-11-01 18:54:12 -0400
commitc094e450a136ffdf4d3e128588b615008a35489e (patch)
tree51d3c4a652720e98d3c95ab1b7d6ebafdc232e45 /expat
parentfc594f380dd766ee363c44395b46f843465ac679 (diff)
downloadlibexpat-git-c094e450a136ffdf4d3e128588b615008a35489e.tar.gz
Fixed some clang -Wcast-qual warnings
Mostly added various missing consts, thus eliminating the casting away of constness. In a few cases, just removed unnecessary casts entirely.
Diffstat (limited to 'expat')
-rw-r--r--expat/lib/xmlparse.c21
-rw-r--r--expat/lib/xmltok.c2
-rw-r--r--expat/tests/runtests.c6
-rw-r--r--expat/xmlwf/xmlwf.c10
4 files changed, 20 insertions, 19 deletions
diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c
index d3b7da04..d9630c6d 100644
--- a/expat/lib/xmlparse.c
+++ b/expat/lib/xmlparse.c
@@ -3046,7 +3046,7 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
/* don't need to check for space - already done in storeAtts() */
while (*localPart)
*uri++ = *localPart++;
- prefix = (XML_Char *)tag->name.prefix;
+ prefix = tag->name.prefix;
if (parser->m_ns_triplets && prefix) {
*uri++ = parser->m_namespaceSeparator;
while (*prefix)
@@ -3142,8 +3142,8 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
(int)(dataPtr - (ICHAR *)parser->m_dataBuf));
} else
parser->m_characterDataHandler(
- parser->m_handlerArg, (XML_Char *)s,
- (int)((XML_Char *)end - (XML_Char *)s));
+ parser->m_handlerArg, (const XML_Char *)s,
+ (int)((const XML_Char *)end - (const XML_Char *)s));
} else if (parser->m_defaultHandler)
reportDefault(parser, enc, s, end);
/* We are at the end of the final buffer, should we check for
@@ -3176,8 +3176,8 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
*eventPP = s;
}
} else
- charDataHandler(parser->m_handlerArg, (XML_Char *)s,
- (int)((XML_Char *)next - (XML_Char *)s));
+ charDataHandler(parser->m_handlerArg, (const XML_Char *)s,
+ (int)((const XML_Char *)next - (const XML_Char *)s));
} else if (parser->m_defaultHandler)
reportDefault(parser, enc, s, next);
} break;
@@ -4092,8 +4092,8 @@ doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr,
*eventPP = s;
}
} else
- charDataHandler(parser->m_handlerArg, (XML_Char *)s,
- (int)((XML_Char *)next - (XML_Char *)s));
+ charDataHandler(parser->m_handlerArg, (const XML_Char *)s,
+ (int)((const XML_Char *)next - (const XML_Char *)s));
} else if (parser->m_defaultHandler)
reportDefault(parser, enc, s, next);
} break;
@@ -6376,8 +6376,9 @@ reportDefault(XML_Parser parser, const ENCODING *enc, const char *s,
} while ((convert_res != XML_CONVERT_COMPLETED)
&& (convert_res != XML_CONVERT_INPUT_INCOMPLETE));
} else
- parser->m_defaultHandler(parser->m_handlerArg, (XML_Char *)s,
- (int)((XML_Char *)end - (XML_Char *)s));
+ parser->m_defaultHandler(
+ parser->m_handlerArg, (const XML_Char *)s,
+ (int)((const XML_Char *)end - (const XML_Char *)s));
}
static int
@@ -7221,7 +7222,7 @@ poolAppend(STRING_POOL *pool, const ENCODING *enc, const char *ptr,
return NULL;
for (;;) {
const enum XML_Convert_Result convert_res = XmlConvert(
- enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end);
+ enc, &ptr, end, (ICHAR **)&(pool->ptr), (const ICHAR *)pool->end);
if ((convert_res == XML_CONVERT_COMPLETED)
|| (convert_res == XML_CONVERT_INPUT_INCOMPLETE))
break;
diff --git a/expat/lib/xmltok.c b/expat/lib/xmltok.c
index c4627935..8654d5a1 100644
--- a/expat/lib/xmltok.c
+++ b/expat/lib/xmltok.c
@@ -243,7 +243,7 @@ static int FASTCALL checkCharRefNumber(int);
#endif
#define SB_BYTE_TYPE(enc, p) \
- (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
+ (((const struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
#ifdef XML_MIN_SIZE
static int PTRFASTCALL
diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c
index 66409f2d..99a09c5b 100644
--- a/expat/tests/runtests.c
+++ b/expat/tests/runtests.c
@@ -3616,7 +3616,7 @@ END_TEST
/* Test user parameter settings */
/* Variable holding the expected handler userData */
-static void *handler_data = NULL;
+static const void *handler_data = NULL;
/* Count of the number of times the comment handler has been invoked */
static int comment_count = 0;
/* Count of the number of skipped entities */
@@ -3768,7 +3768,7 @@ START_TEST(test_ext_entity_ref_parameter) {
* what NULL would cause to be passed.
*/
XML_SetExternalEntityRefHandlerArg(g_parser, (void *)text);
- handler_data = (void *)text;
+ handler_data = text;
if (_XML_Parse_SINGLE_BYTES(g_parser, text, (int)strlen(text), XML_TRUE)
== XML_STATUS_ERROR)
xml_failure(g_parser);
@@ -3778,7 +3778,7 @@ START_TEST(test_ext_entity_ref_parameter) {
XML_SetParamEntityParsing(g_parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
XML_SetExternalEntityRefHandler(g_parser, external_entity_ref_param_checker);
XML_SetExternalEntityRefHandlerArg(g_parser, NULL);
- handler_data = (void *)g_parser;
+ handler_data = g_parser;
if (_XML_Parse_SINGLE_BYTES(g_parser, text, (int)strlen(text), XML_TRUE)
== XML_STATUS_ERROR)
xml_failure(g_parser);
diff --git a/expat/xmlwf/xmlwf.c b/expat/xmlwf/xmlwf.c
index 00ebdc9e..7fba67d9 100644
--- a/expat/xmlwf/xmlwf.c
+++ b/expat/xmlwf/xmlwf.c
@@ -178,7 +178,7 @@ is equivalent to lexicographically comparing based on the character number. */
static int
attcmp(const void *att1, const void *att2) {
- return tcscmp(*(const XML_Char **)att1, *(const XML_Char **)att2);
+ return tcscmp(*(const XML_Char *const *)att1, *(const XML_Char *const *)att2);
}
static void XMLCALL
@@ -215,8 +215,8 @@ endElement(void *userData, const XML_Char *name) {
static int
nsattcmp(const void *p1, const void *p2) {
- const XML_Char *att1 = *(const XML_Char **)p1;
- const XML_Char *att2 = *(const XML_Char **)p2;
+ const XML_Char *att1 = *(const XML_Char *const *)p1;
+ const XML_Char *att2 = *(const XML_Char *const *)p2;
int sep1 = (tcsrchr(att1, NSSEP) != 0);
int sep2 = (tcsrchr(att2, NSSEP) != 0);
if (sep1 != sep2)
@@ -370,8 +370,8 @@ xcscmp(const XML_Char *xs, const XML_Char *xt) {
static int
notationCmp(const void *a, const void *b) {
- const NotationList *const n1 = *(NotationList **)a;
- const NotationList *const n2 = *(NotationList **)b;
+ const NotationList *const n1 = *(const NotationList *const *)a;
+ const NotationList *const n2 = *(const NotationList *const *)b;
return xcscmp(n1->notationName, n2->notationName);
}