From fc2dd942fc61ae135b7e2bfe5c248b1f15b74547 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Sat, 27 Feb 2016 11:45:51 +0100 Subject: Fixed most compiler warnings -Wall -Wextra repro: CFLAGS="-Wall -Wextra -Wunused-parameter -Wc++-compat" ./configure && make which we use for perl, and libyaml is now included in cperl. Tested with gcc-5 and clang-3.7 There are still a tons of format warnings (%d on 64bit) in example-deconstructor.c which I skipped. --- tests/example-deconstructor.c | 40 ++++++++++++++++++++-------------------- tests/example-reformatter.c | 40 ++++++++++++++++++++-------------------- tests/run-dumper.c | 6 +++--- tests/run-emitter.c | 6 +++--- tests/test-reader.c | 28 ++++++++++++++-------------- tests/test-version.c | 6 +++--- 6 files changed, 63 insertions(+), 63 deletions(-) (limited to 'tests') diff --git a/tests/example-deconstructor.c b/tests/example-deconstructor.c index e904201..e048ee6 100644 --- a/tests/example-deconstructor.c +++ b/tests/example-deconstructor.c @@ -1033,42 +1033,42 @@ parser_error: case YAML_READER_ERROR: if (parser.problem_value != -1) { - fprintf(stderr, "Reader error: %s: #%X at %zu\n", parser.problem, - parser.problem_value, parser.problem_offset); + fprintf(stderr, "Reader error: %s: #%X at %ld\n", parser.problem, + parser.problem_value, (long)parser.problem_offset); } else { - fprintf(stderr, "Reader error: %s at %zu\n", parser.problem, - parser.problem_offset); + fprintf(stderr, "Reader error: %s at %ld\n", parser.problem, + (long)parser.problem_offset); } break; case YAML_SCANNER_ERROR: if (parser.context) { - fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n" - "%s at line %lu, column %lu\n", parser.context, - parser.context_mark.line+1, parser.context_mark.column+1, - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + fprintf(stderr, "Scanner error: %s at line %d, column %d\n" + "%s at line %d, column %d\n", parser.context, + (int)parser.context_mark.line+1, (int)parser.context_mark.column+1, + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } else { - fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n", - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + fprintf(stderr, "Scanner error: %s at line %d, column %d\n", + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } break; case YAML_PARSER_ERROR: if (parser.context) { - fprintf(stderr, "Parser error: %s at line %lu, column %lu\n" - "%s at line %lu, column %lu\n", parser.context, - parser.context_mark.line+1, parser.context_mark.column+1, - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + fprintf(stderr, "Parser error: %s at line %d, column %d\n" + "%s at line %d, column %d\n", parser.context, + (int)parser.context_mark.line+1, (int)parser.context_mark.column+1, + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } else { - fprintf(stderr, "Parser error: %s at line %lu, column %lu\n", - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + fprintf(stderr, "Parser error: %s at line %d, column %d\n", + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } break; diff --git a/tests/example-reformatter.c b/tests/example-reformatter.c index 306c742..08f860c 100644 --- a/tests/example-reformatter.c +++ b/tests/example-reformatter.c @@ -120,42 +120,42 @@ parser_error: case YAML_READER_ERROR: if (parser.problem_value != -1) { - fprintf(stderr, "Reader error: %s: #%X at %zd\n", parser.problem, - parser.problem_value, parser.problem_offset); + fprintf(stderr, "Reader error: %s: #%X at %ld\n", parser.problem, + parser.problem_value, (long)parser.problem_offset); } else { - fprintf(stderr, "Reader error: %s at %zd\n", parser.problem, - parser.problem_offset); + fprintf(stderr, "Reader error: %s at %ld\n", parser.problem, + (long)parser.problem_offset); } break; case YAML_SCANNER_ERROR: if (parser.context) { - fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n" - "%s at line %lu, column %lu\n", parser.context, - parser.context_mark.line+1, parser.context_mark.column+1, - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + fprintf(stderr, "Scanner error: %s at line %d, column %d\n" + "%s at line %d, column %d\n", parser.context, + (int)parser.context_mark.line+1, (int)parser.context_mark.column+1, + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } else { - fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n", - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + fprintf(stderr, "Scanner error: %s at line %d, column %d\n", + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } break; case YAML_PARSER_ERROR: if (parser.context) { - fprintf(stderr, "Parser error: %s at line %lu, column %lu\n" - "%s at line %lu, column %lu\n", parser.context, - parser.context_mark.line+1, parser.context_mark.column+1, - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + fprintf(stderr, "Parser error: %s at line %d, column %d\n" + "%s at line %d, column %d\n", parser.context, + (int)parser.context_mark.line+1, (int)parser.context_mark.column+1, + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } else { - fprintf(stderr, "Parser error: %s at line %lu, column %lu\n", - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + fprintf(stderr, "Parser error: %s at line %d, column %d\n", + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } break; diff --git a/tests/run-dumper.c b/tests/run-dumper.c index 6236ee1..302b9b9 100644 --- a/tests/run-dumper.c +++ b/tests/run-dumper.c @@ -180,8 +180,8 @@ int print_output(char *name, unsigned char *buffer, size_t size, int count) if (feof(file)) break; } fclose(file); - printf("#### (length: %zd)\n", total_size); - printf("OUTPUT:\n%s#### (length: %zd)\n", buffer, size); + printf("#### (length: %ld)\n", (long)total_size); + printf("OUTPUT:\n%s#### (length: %ld)\n", buffer, (long)size); return 0; } @@ -304,7 +304,7 @@ main(int argc, char *argv[]) yaml_document_delete(documents+k); } - printf("PASSED (length: %zd)\n", written); + printf("PASSED (length: %ld)\n", (long)written); print_output(argv[number], buffer, written, -1); } diff --git a/tests/run-emitter.c b/tests/run-emitter.c index fee2922..4996a85 100644 --- a/tests/run-emitter.c +++ b/tests/run-emitter.c @@ -205,8 +205,8 @@ int print_output(char *name, unsigned char *buffer, size_t size, int count) if (feof(file)) break; } fclose(file); - printf("#### (length: %zd)\n", total_size); - printf("OUTPUT:\n%s#### (length: %zd)\n", buffer, size); + printf("#### (length: %ld)\n", (long)total_size); + printf("OUTPUT:\n%s#### (length: %ld)\n", buffer, (long)size); return 0; } @@ -319,7 +319,7 @@ main(int argc, char *argv[]) yaml_event_delete(events+k); } - printf("PASSED (length: %zd)\n", written); + printf("PASSED (length: %ld)\n", (long)written); print_output(argv[number], buffer, written, -1); } diff --git a/tests/test-reader.c b/tests/test-reader.c index 2ecb292..40f8199 100644 --- a/tests/test-reader.c +++ b/tests/test-reader.c @@ -144,12 +144,12 @@ int check_utf8_sequences(void) } else if (parser.error == YAML_READER_ERROR) { if (parser.problem_value != -1) { - printf("(reader error: %s: #%X at %zu)\n", - parser.problem, parser.problem_value, parser.problem_offset); + printf("(reader error: %s: #%X at %ld)\n", + parser.problem, parser.problem_value, (long)parser.problem_offset); } else { - printf("(reader error: %s at %zu)\n", - parser.problem, parser.problem_offset); + printf("(reader error: %s at %ld)\n", + parser.problem, (long)parser.problem_offset); } } if (*end == '!') break; @@ -180,12 +180,12 @@ int check_boms(void) yaml_parser_set_input_string(&parser, (unsigned char *)start, end-start); result = yaml_parser_update_buffer(&parser, end-start); if (!result) { - printf("- (reader error: %s at %zu)\n", parser.problem, parser.problem_offset); + printf("- (reader error: %s at %ld)\n", parser.problem, (long)parser.problem_offset); failed++; } else { if (parser.unread != check) { - printf("- (length=%zu while expected length=%d)\n", parser.unread, check); + printf("- (length=%ld while expected length=%d)\n", (long)parser.unread, check); failed++; } else if (memcmp(parser.buffer.start, bom_original, check) != 0) { @@ -211,7 +211,7 @@ int check_long_utf8(void) int j; int failed = 0; unsigned char ch0, ch1; - unsigned char *buffer = malloc(3+LONG*2); + unsigned char *buffer = (unsigned char *)malloc(3+LONG*2); assert(buffer); printf("checking a long utf8 sequence...\n"); buffer[k++] = '\xef'; @@ -232,7 +232,7 @@ int check_long_utf8(void) for (k = 0; k < LONG; k++) { if (!parser.unread) { if (!yaml_parser_update_buffer(&parser, 1)) { - printf("\treader error: %s at %zu\n", parser.problem, parser.problem_offset); + printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset); failed = 1; break; } @@ -262,11 +262,11 @@ int check_long_utf8(void) } if (!failed) { if (!yaml_parser_update_buffer(&parser, 1)) { - printf("\treader error: %s at %zu\n", parser.problem, parser.problem_offset); + printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset); failed = 1; } else if (parser.buffer.pointer[0] != '\0') { - printf("\texpected NUL, found %X (eof=%d, unread=%zu)\n", (int)parser.buffer.pointer[0], parser.eof, parser.unread); + printf("\texpected NUL, found %X (eof=%d, unread=%ld)\n", (int)parser.buffer.pointer[0], parser.eof, (long)parser.unread); failed = 1; } } @@ -283,7 +283,7 @@ int check_long_utf16(void) int j; int failed = 0; unsigned char ch0, ch1; - unsigned char *buffer = malloc(2+LONG*2); + unsigned char *buffer = (unsigned char *)malloc(2+LONG*2); assert(buffer); printf("checking a long utf16 sequence...\n"); buffer[k++] = '\xff'; @@ -303,7 +303,7 @@ int check_long_utf16(void) for (k = 0; k < LONG; k++) { if (!parser.unread) { if (!yaml_parser_update_buffer(&parser, 1)) { - printf("\treader error: %s at %zu\n", parser.problem, parser.problem_offset); + printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset); failed = 1; break; } @@ -333,11 +333,11 @@ int check_long_utf16(void) } if (!failed) { if (!yaml_parser_update_buffer(&parser, 1)) { - printf("\treader error: %s at %zu\n", parser.problem, parser.problem_offset); + printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset); failed = 1; } else if (parser.buffer.pointer[0] != '\0') { - printf("\texpected NUL, found %X (eof=%d, unread=%zu)\n", (int)parser.buffer.pointer[0], parser.eof, parser.unread); + printf("\texpected NUL, found %X (eof=%d, unread=%ld)\n", (int)parser.buffer.pointer[0], parser.eof, (long)parser.unread); failed = 1; } } diff --git a/tests/test-version.c b/tests/test-version.c index 69ae5bb..0c59837 100644 --- a/tests/test-version.c +++ b/tests/test-version.c @@ -21,9 +21,9 @@ main(void) assert(strcmp(buf, yaml_get_version_string()) == 0); /* Print structure sizes. */ - printf("sizeof(token) = %lu\n", sizeof(yaml_token_t)); - printf("sizeof(event) = %lu\n", sizeof(yaml_event_t)); - printf("sizeof(parser) = %lu\n", sizeof(yaml_parser_t)); + printf("sizeof(token) = %ld\n", (long)sizeof(yaml_token_t)); + printf("sizeof(event) = %ld\n", (long)sizeof(yaml_event_t)); + printf("sizeof(parser) = %ld\n", (long)sizeof(yaml_parser_t)); return 0; } -- cgit v1.2.1