From aa4c1c73b08619e80ac9ccb6bb64a93458c412ed Mon Sep 17 00:00:00 2001 From: "Serge A. Zaitsev" Date: Sat, 30 Mar 2019 21:20:44 +0100 Subject: [PATCH] fix clang warnings --- test/tests.c | 6 +++--- test/testutil.h | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/test/tests.c b/test/tests.c index 778e75b..d8a4d92 100644 --- a/test/tests.c +++ b/test/tests.c @@ -97,8 +97,8 @@ int test_string(void) { } int test_partial_string(void) { - int i; int r; + unsigned long i; jsmn_parser p; jsmntok_t tok[5]; const char *js = "{\"x\": \"va\\\\ue\", \"y\": \"value y\"}"; @@ -121,7 +121,7 @@ int test_partial_string(void) { int test_partial_array(void) { #ifdef JSMN_STRICT int r; - int i; + unsigned long i; jsmn_parser p; jsmntok_t tok[10]; const char *js = "[ 1, true, [123, \"hello\"]]"; @@ -291,7 +291,7 @@ int test_nonstrict(void) { JSMN_PRIMITIVE, "Month", JSMN_PRIMITIVE, "Sep", JSMN_PRIMITIVE, "Year", JSMN_PRIMITIVE, "12")); - // nested {s don't cause a parse error. + /* nested {s don't cause a parse error. */ js = "\"key {1\": 1234"; check(parse(js, 2, 2, JSMN_STRING, "key {1", 1, JSMN_PRIMITIVE, "1234")); diff --git a/test/testutil.h b/test/testutil.h index 6574153..b4a51b5 100644 --- a/test/testutil.h +++ b/test/testutil.h @@ -3,9 +3,11 @@ #include "../jsmn.h" -static int vtokeq(const char *s, jsmntok_t *t, int numtok, va_list ap) { +static int vtokeq(const char *s, jsmntok_t *t, unsigned long numtok, + va_list ap) { if (numtok > 0) { - int i, start, end, size; + unsigned long i; + int start, end, size; int type; char *value; @@ -27,29 +29,29 @@ static int vtokeq(const char *s, jsmntok_t *t, int numtok, va_list ap) { value = NULL; } if (t[i].type != type) { - printf("token %d type is %d, not %d\n", i, t[i].type, type); + printf("token %lu type is %d, not %d\n", i, t[i].type, type); return 0; } if (start != -1 && end != -1) { if (t[i].start != start) { - printf("token %d start is %d, not %d\n", i, t[i].start, start); + printf("token %lu start is %d, not %d\n", i, t[i].start, start); return 0; } if (t[i].end != end) { - printf("token %d end is %d, not %d\n", i, t[i].end, end); + printf("token %lu end is %d, not %d\n", i, t[i].end, end); return 0; } } if (size != -1 && t[i].size != size) { - printf("token %d size is %d, not %d\n", i, t[i].size, size); + printf("token %lu size is %d, not %d\n", i, t[i].size, size); return 0; } if (s != NULL && value != NULL) { const char *p = s + t[i].start; - if (strlen(value) != t[i].end - t[i].start || + if (strlen(value) != (unsigned long)(t[i].end - t[i].start) || strncmp(p, value, t[i].end - t[i].start) != 0) { - printf("token %d value is %.*s, not %s\n", i, t[i].end - t[i].start, + printf("token %lu value is %.*s, not %s\n", i, t[i].end - t[i].start, s + t[i].start, value); return 0; }