| @@ -1,2 +1,2 @@ | |||||
| AM_CFLAGS = -Wall -Wextra -Wwrite-strings -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -D_REENTRANT | |||||
| AM_CFLAGS = -Wall -Werror -Wextra -Wwrite-strings -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -D_REENTRANT | |||||
| @@ -69,7 +69,8 @@ const char* json_tokener_errors[] = { | |||||
| const char *json_tokener_error_desc(enum json_tokener_error jerr) | const char *json_tokener_error_desc(enum json_tokener_error jerr) | ||||
| { | { | ||||
| if (jerr < 0 || jerr > sizeof(json_tokener_errors)) | |||||
| int jerr_int = (int)jerr; | |||||
| if (jerr_int < 0 || jerr_int > (int)sizeof(json_tokener_errors)) | |||||
| return "Unknown error, invalid json_tokener_error value passed to json_tokener_error_desc()"; | return "Unknown error, invalid json_tokener_error value passed to json_tokener_error_desc()"; | ||||
| return json_tokener_errors[jerr]; | return json_tokener_errors[jerr]; | ||||
| } | } | ||||
| @@ -91,7 +92,7 @@ struct json_tokener* json_tokener_new_ex(int depth) | |||||
| tok = (struct json_tokener*)calloc(1, sizeof(struct json_tokener)); | tok = (struct json_tokener*)calloc(1, sizeof(struct json_tokener)); | ||||
| if (!tok) return NULL; | if (!tok) return NULL; | ||||
| tok->stack = (struct json_tokener*)calloc(depth, sizeof(struct json_tokener_srec)); | |||||
| tok->stack = (struct json_tokener_srec *)calloc(depth, sizeof(struct json_tokener_srec)); | |||||
| if (!tok->stack) { | if (!tok->stack) { | ||||
| free(tok); | free(tok); | ||||
| return NULL; | return NULL; | ||||
| @@ -330,8 +331,8 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, | |||||
| case json_tokener_state_null: | case json_tokener_state_null: | ||||
| printbuf_memappend_fast(tok->pb, &c, 1); | printbuf_memappend_fast(tok->pb, &c, 1); | ||||
| if(strncasecmp(json_null_str, tok->pb->buf, | if(strncasecmp(json_null_str, tok->pb->buf, | ||||
| json_min(tok->st_pos+1, strlen(json_null_str))) == 0) { | |||||
| if(tok->st_pos == strlen(json_null_str)) { | |||||
| json_min(tok->st_pos+1, (int)strlen(json_null_str))) == 0) { | |||||
| if(tok->st_pos == (int)strlen(json_null_str)) { | |||||
| current = NULL; | current = NULL; | ||||
| saved_state = json_tokener_state_finish; | saved_state = json_tokener_state_finish; | ||||
| state = json_tokener_state_eatws; | state = json_tokener_state_eatws; | ||||
| @@ -552,16 +553,16 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, | |||||
| case json_tokener_state_boolean: | case json_tokener_state_boolean: | ||||
| printbuf_memappend_fast(tok->pb, &c, 1); | printbuf_memappend_fast(tok->pb, &c, 1); | ||||
| if(strncasecmp(json_true_str, tok->pb->buf, | if(strncasecmp(json_true_str, tok->pb->buf, | ||||
| json_min(tok->st_pos+1, strlen(json_true_str))) == 0) { | |||||
| if(tok->st_pos == strlen(json_true_str)) { | |||||
| json_min(tok->st_pos+1, (int)strlen(json_true_str))) == 0) { | |||||
| if(tok->st_pos == (int)strlen(json_true_str)) { | |||||
| current = json_object_new_boolean(1); | current = json_object_new_boolean(1); | ||||
| saved_state = json_tokener_state_finish; | saved_state = json_tokener_state_finish; | ||||
| state = json_tokener_state_eatws; | state = json_tokener_state_eatws; | ||||
| goto redo_char; | goto redo_char; | ||||
| } | } | ||||
| } else if(strncasecmp(json_false_str, tok->pb->buf, | } else if(strncasecmp(json_false_str, tok->pb->buf, | ||||
| json_min(tok->st_pos+1, strlen(json_false_str))) == 0) { | |||||
| if(tok->st_pos == strlen(json_false_str)) { | |||||
| json_min(tok->st_pos+1, (int)strlen(json_false_str))) == 0) { | |||||
| if(tok->st_pos == (int)strlen(json_false_str)) { | |||||
| current = json_object_new_boolean(0); | current = json_object_new_boolean(0); | ||||
| saved_state = json_tokener_state_finish; | saved_state = json_tokener_state_finish; | ||||
| state = json_tokener_state_eatws; | state = json_tokener_state_eatws; | ||||
| @@ -194,7 +194,7 @@ int json_parse_int64(const char *buf, int64_t *retval) | |||||
| */ | */ | ||||
| if (orig_has_neg != recheck_has_neg || | if (orig_has_neg != recheck_has_neg || | ||||
| strncmp(buf_skip_space, buf_cmp_start, strlen(buf_cmp_start)) != 0 || | strncmp(buf_skip_space, buf_cmp_start, strlen(buf_cmp_start)) != 0 || | ||||
| (strlen(buf_skip_space) != buf_cmp_len && | |||||
| ((int)strlen(buf_skip_space) != buf_cmp_len && | |||||
| isdigit((int)buf_skip_space[buf_cmp_len]) | isdigit((int)buf_skip_space[buf_cmp_len]) | ||||
| ) | ) | ||||
| ) | ) | ||||
| @@ -238,7 +238,8 @@ static const char* json_type_name[] = { | |||||
| const char *json_type_to_name(enum json_type o_type) | const char *json_type_to_name(enum json_type o_type) | ||||
| { | { | ||||
| if (o_type < 0 || o_type >= NELEM(json_type_name)) | |||||
| int o_type_int = (int)o_type; | |||||
| if (o_type_int < 0 || o_type_int >= (int)NELEM(json_type_name)) | |||||
| { | { | ||||
| MC_ERROR("json_type_to_name: type %d is out of range [0,%d]\n", o_type, NELEM(json_type_name)); | MC_ERROR("json_type_to_name: type %d is out of range [0,%d]\n", o_type, NELEM(json_type_name)); | ||||
| return NULL; | return NULL; | ||||
| @@ -134,7 +134,7 @@ int lh_table_insert(struct lh_table *t, void *k, const void *v) | |||||
| while( 1 ) { | while( 1 ) { | ||||
| if(t->table[n].k == LH_EMPTY || t->table[n].k == LH_FREED) break; | if(t->table[n].k == LH_EMPTY || t->table[n].k == LH_FREED) break; | ||||
| t->collisions++; | t->collisions++; | ||||
| if(++n == t->size) n = 0; | |||||
| if ((int)++n == t->size) n = 0; | |||||
| } | } | ||||
| t->table[n].k = k; | t->table[n].k = k; | ||||
| @@ -166,7 +166,7 @@ struct lh_entry* lh_table_lookup_entry(struct lh_table *t, const void *k) | |||||
| if(t->table[n].k == LH_EMPTY) return NULL; | if(t->table[n].k == LH_EMPTY) return NULL; | ||||
| if(t->table[n].k != LH_FREED && | if(t->table[n].k != LH_FREED && | ||||
| t->equal_fn(t->table[n].k, k)) return &t->table[n]; | t->equal_fn(t->table[n].k, k)) return &t->table[n]; | ||||
| if(++n == t->size) n = 0; | |||||
| if ((int)++n == t->size) n = 0; | |||||
| count++; | count++; | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| @@ -32,7 +32,7 @@ int parse_flags(int argc, char **argv) | |||||
| for (arg_idx = 1; arg_idx < argc ; arg_idx++) | for (arg_idx = 1; arg_idx < argc ; arg_idx++) | ||||
| { | { | ||||
| int jj; | int jj; | ||||
| for (jj = 0; jj < NELEM(format_args); jj++) | |||||
| for (jj = 0; jj < (int)NELEM(format_args); jj++) | |||||
| { | { | ||||
| if (strcasecmp(argv[arg_idx], format_args[jj].arg) == 0) | if (strcasecmp(argv[arg_idx], format_args[jj].arg) == 0) | ||||
| { | { | ||||
| @@ -183,7 +183,7 @@ struct incremental_step { | |||||
| { "[1,2,3,]", -1, -1, json_tokener_success, 0 }, | { "[1,2,3,]", -1, -1, json_tokener_success, 0 }, | ||||
| { "[1,2,,3,]", -1, 5, json_tokener_error_parse_unexpected, 0 }, | { "[1,2,,3,]", -1, 5, json_tokener_error_parse_unexpected, 0 }, | ||||
| { NULL, json_tokener_success }, | |||||
| { NULL, -1, -1, json_tokener_success, 0 }, | |||||
| }; | }; | ||||
| static void test_incremental_parse() | static void test_incremental_parse() | ||||
| @@ -86,7 +86,7 @@ static void test_printbuf_memappend(int *before_resize) | |||||
| char with_nulls[] = { 'a', 'b', '\0', 'c' }; | char with_nulls[] = { 'a', 'b', '\0', 'c' }; | ||||
| printbuf_reset(pb); | printbuf_reset(pb); | ||||
| printbuf_memappend_fast(pb, with_nulls, sizeof(with_nulls)); | |||||
| printbuf_memappend_fast(pb, with_nulls, (int)sizeof(with_nulls)); | |||||
| printf("With embedded \\0 character: %d, [%s]\n", printbuf_length(pb), pb->buf); | printf("With embedded \\0 character: %d, [%s]\n", printbuf_length(pb), pb->buf); | ||||
| printbuf_free(pb); | printbuf_free(pb); | ||||