mirror of
https://github.com/libexpat/libexpat.git
synced 2025-04-06 13:45:00 +00:00
tests: Address clang-tidy warning bugprone-narrowing-conversions
The symptom was:
> [..]/expat/tests/alloc_tests.c:326:26: error: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 326 | g_allocation_count = i;
> | ^
> [..]/expat/tests/alloc_tests.c:437:26: error: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 437 | g_allocation_count = i;
> | ^
> [..]/expat/tests/basic_tests.c:415:47: error: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 415 | if (_XML_Parse_SINGLE_BYTES(g_parser, text, first_chunk_bytes, XML_FALSE)
> | ^
> [..]/expat/tests/basic_tests.c:421:34: error: narrowing conversion from 'unsigned long' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 421 | sizeof(text) - first_chunk_bytes - 1,
> | ^
> [..]/expat/tests/handlers.c:92:37: error: narrowing conversion from 'XML_Size' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 92 | StructData_AddItem(storage, name, XML_GetCurrentColumnNumber(g_parser),
> | ^
> [..]/expat/tests/handlers.c:93:22: error: narrowing conversion from 'XML_Size' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 93 | XML_GetCurrentLineNumber(g_parser), STRUCT_START_TAG);
> | ^
> [..]/expat/tests/handlers.c:99:37: error: narrowing conversion from 'XML_Size' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 99 | StructData_AddItem(storage, name, XML_GetCurrentColumnNumber(g_parser),
> | ^
> [..]/expat/tests/handlers.c💯22: error: narrowing conversion from 'XML_Size' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 100 | XML_GetCurrentLineNumber(g_parser), STRUCT_END_TAG);
> | ^
> [..]/expat/tests/handlers.c:1279:26: error: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 1279 | g_allocation_count = i;
> | ^
> [..]/expat/tests/misc_tests.c:73:26: error: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 73 | g_allocation_count = i;
> | ^
> [..]/expat/tests/misc_tests.c:93:26: error: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 93 | g_allocation_count = i;
> | ^
> [..]/expat/tests/nsalloc_tests.c:86:26: error: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 86 | g_allocation_count = i;
> | ^
> [..]/expat/tests/nsalloc_tests.c:526:28: error: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,-warnings-as-errors]
> 526 | g_reallocation_count = i;
> | ^
This commit is contained in:
parent
2ae87fa583
commit
94cceb228c
5 changed files with 13 additions and 13 deletions
|
@ -323,7 +323,7 @@ START_TEST(test_alloc_run_external_parser) {
|
|||
XML_SetParamEntityParsing(g_parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
|
||||
XML_SetUserData(g_parser, foo_text);
|
||||
XML_SetExternalEntityRefHandler(g_parser, external_entity_null_loader);
|
||||
g_allocation_count = i;
|
||||
g_allocation_count = (int)i;
|
||||
if (_XML_Parse_SINGLE_BYTES(g_parser, text, (int)strlen(text), XML_TRUE)
|
||||
!= XML_STATUS_ERROR)
|
||||
break;
|
||||
|
@ -434,7 +434,7 @@ START_TEST(test_alloc_internal_entity) {
|
|||
const unsigned int max_alloc_count = 20;
|
||||
|
||||
for (i = 0; i < max_alloc_count; i++) {
|
||||
g_allocation_count = i;
|
||||
g_allocation_count = (int)i;
|
||||
XML_SetUnknownEncodingHandler(g_parser, unknown_released_encoding_handler,
|
||||
NULL);
|
||||
if (_XML_Parse_SINGLE_BYTES(g_parser, text, (int)strlen(text), XML_TRUE)
|
||||
|
|
|
@ -412,13 +412,13 @@ START_TEST(test_utf16_le_epilog_newline) {
|
|||
|
||||
if (first_chunk_bytes >= sizeof(text) - 1)
|
||||
fail("bad value of first_chunk_bytes");
|
||||
if (_XML_Parse_SINGLE_BYTES(g_parser, text, first_chunk_bytes, XML_FALSE)
|
||||
if (_XML_Parse_SINGLE_BYTES(g_parser, text, (int)first_chunk_bytes, XML_FALSE)
|
||||
== XML_STATUS_ERROR)
|
||||
xml_failure(g_parser);
|
||||
else {
|
||||
enum XML_Status rc;
|
||||
rc = _XML_Parse_SINGLE_BYTES(g_parser, text + first_chunk_bytes,
|
||||
sizeof(text) - first_chunk_bytes - 1,
|
||||
(int)(sizeof(text) - first_chunk_bytes - 1),
|
||||
XML_TRUE);
|
||||
if (rc == XML_STATUS_ERROR)
|
||||
xml_failure(g_parser);
|
||||
|
|
|
@ -89,15 +89,15 @@ start_element_event_handler2(void *userData, const XML_Char *name,
|
|||
const XML_Char **attr) {
|
||||
StructData *storage = (StructData *)userData;
|
||||
UNUSED_P(attr);
|
||||
StructData_AddItem(storage, name, XML_GetCurrentColumnNumber(g_parser),
|
||||
XML_GetCurrentLineNumber(g_parser), STRUCT_START_TAG);
|
||||
StructData_AddItem(storage, name, (int)XML_GetCurrentColumnNumber(g_parser),
|
||||
(int)XML_GetCurrentLineNumber(g_parser), STRUCT_START_TAG);
|
||||
}
|
||||
|
||||
void XMLCALL
|
||||
end_element_event_handler2(void *userData, const XML_Char *name) {
|
||||
StructData *storage = (StructData *)userData;
|
||||
StructData_AddItem(storage, name, XML_GetCurrentColumnNumber(g_parser),
|
||||
XML_GetCurrentLineNumber(g_parser), STRUCT_END_TAG);
|
||||
StructData_AddItem(storage, name, (int)XML_GetCurrentColumnNumber(g_parser),
|
||||
(int)XML_GetCurrentLineNumber(g_parser), STRUCT_END_TAG);
|
||||
}
|
||||
|
||||
void XMLCALL
|
||||
|
@ -1276,7 +1276,7 @@ external_entity_duff_loader(XML_Parser parser, const XML_Char *context,
|
|||
UNUSED_P(publicId);
|
||||
/* Try a few different allocation levels */
|
||||
for (i = 0; i < max_alloc_count; i++) {
|
||||
g_allocation_count = i;
|
||||
g_allocation_count = (int)i;
|
||||
new_parser = XML_ExternalEntityParserCreate(parser, context, NULL);
|
||||
if (new_parser != NULL) {
|
||||
XML_ParserFree(new_parser);
|
||||
|
|
|
@ -70,7 +70,7 @@ START_TEST(test_misc_alloc_create_parser) {
|
|||
|
||||
/* Something this simple shouldn't need more than 10 allocations */
|
||||
for (i = 0; i < max_alloc_count; i++) {
|
||||
g_allocation_count = i;
|
||||
g_allocation_count = (int)i;
|
||||
g_parser = XML_ParserCreate_MM(NULL, &memsuite, NULL);
|
||||
if (g_parser != NULL)
|
||||
break;
|
||||
|
@ -90,7 +90,7 @@ START_TEST(test_misc_alloc_create_parser_with_encoding) {
|
|||
|
||||
/* Try several levels of allocation */
|
||||
for (i = 0; i < max_alloc_count; i++) {
|
||||
g_allocation_count = i;
|
||||
g_allocation_count = (int)i;
|
||||
g_parser = XML_ParserCreate_MM(XCS("us-ascii"), &memsuite, NULL);
|
||||
if (g_parser != NULL)
|
||||
break;
|
||||
|
|
|
@ -83,7 +83,7 @@ START_TEST(test_nsalloc_xmlns) {
|
|||
const unsigned int max_alloc_count = 30;
|
||||
|
||||
for (i = 0; i < max_alloc_count; i++) {
|
||||
g_allocation_count = i;
|
||||
g_allocation_count = (int)i;
|
||||
/* Exercise more code paths with a default handler */
|
||||
XML_SetDefaultHandler(g_parser, dummy_default_handler);
|
||||
if (_XML_Parse_SINGLE_BYTES(g_parser, text, (int)strlen(text), XML_TRUE)
|
||||
|
@ -523,7 +523,7 @@ START_TEST(test_nsalloc_realloc_binding_uri) {
|
|||
/* Now repeat with a longer URI and a duff reallocator */
|
||||
for (i = 0; i < max_realloc_count; i++) {
|
||||
XML_ParserReset(g_parser, NULL);
|
||||
g_reallocation_count = i;
|
||||
g_reallocation_count = (int)i;
|
||||
if (_XML_Parse_SINGLE_BYTES(g_parser, second, (int)strlen(second), XML_TRUE)
|
||||
!= XML_STATUS_ERROR)
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue