diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index eab0f17a..205cb04b 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; @@ -8394,7 +8395,7 @@ getDebugLevel(const char *variableName, unsigned long defaultDebugLevel) { const char *const value = valueOrNull; errno = 0; - char *afterValue = (char *)value; + char *afterValue = NULL; unsigned long debugLevel = strtoul(value, &afterValue, 10); if ((errno != 0) || (afterValue == value) || (afterValue[0] != '\0')) { errno = 0; diff --git a/expat/lib/xmltok.c b/expat/lib/xmltok.c index c4627935..22821cb8 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 @@ -407,7 +407,7 @@ utf8_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short *to = *toP; const char *from = *fromP; while (from < fromLim && to < toLim) { - switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) { + switch (SB_BYTE_TYPE(enc, from)) { case BT_LEAD2: if (fromLim - from < 2) { res = XML_CONVERT_INPUT_INCOMPLETE; @@ -734,8 +734,7 @@ DEFINE_UTF16_TO_UTF16(big2_) #undef GET_HI #define LITTLE2_BYTE_TYPE(enc, p) \ - ((p)[1] == 0 ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \ - : unicode_byte_type((p)[1], (p)[0])) + ((p)[1] == 0 ? SB_BYTE_TYPE(enc, p) : unicode_byte_type((p)[1], (p)[0])) #define LITTLE2_BYTE_TO_ASCII(p) ((p)[1] == 0 ? (p)[0] : -1) #define LITTLE2_CHAR_MATCHES(p, c) ((p)[1] == 0 && (p)[0] == (c)) #define LITTLE2_IS_NAME_CHAR_MINBPC(p) \ @@ -868,9 +867,7 @@ static const struct normal_encoding internal_little2_encoding #endif #define BIG2_BYTE_TYPE(enc, p) \ - ((p)[0] == 0 \ - ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \ - : unicode_byte_type((p)[0], (p)[1])) + ((p)[0] == 0 ? SB_BYTE_TYPE(enc, p + 1) : unicode_byte_type((p)[0], (p)[1])) #define BIG2_BYTE_TO_ASCII(p) ((p)[0] == 0 ? (p)[1] : -1) #define BIG2_CHAR_MATCHES(p, c) ((p)[0] == 0 && (p)[1] == (c)) #define BIG2_IS_NAME_CHAR_MINBPC(p) \ 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 499825ed..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); } @@ -1051,7 +1051,7 @@ tmain(int argc, XML_Char **argv) { XMLWF_SHIFT_ARG_INTO(valueText, argc, argv, i, j); errno = 0; - XML_Char *afterValueText = (XML_Char *)valueText; + XML_Char *afterValueText = NULL; attackMaximumAmplification = tcstof(valueText, &afterValueText); if ((errno != 0) || (afterValueText[0] != T('\0')) || isnan(attackMaximumAmplification)