@@ -84,7 +84,7 @@ static int parseit(int fd, int (*callback)(struct json_object *)) | |||||
// everything you can do with a tokener into json_util.c seems | // everything you can do with a tokener into json_util.c seems | ||||
// like the wrong approach. | // like the wrong approach. | ||||
size_t total_read = 0; | size_t total_read = 0; | ||||
while ((ret = read(fd, buf, sizeof(buf))) > 0) | |||||
while ((ret = (int)read(fd, buf, sizeof(buf))) > 0) | |||||
{ | { | ||||
total_read += ret; | total_read += ret; | ||||
int start_pos = 0; | int start_pos = 0; | ||||
@@ -98,7 +98,7 @@ static int parseit(int fd, int (*callback)(struct json_object *)) | |||||
const char *aterr = (start_pos + parse_end < (int)sizeof(buf)) ? | const char *aterr = (start_pos + parse_end < (int)sizeof(buf)) ? | ||||
&buf[start_pos + parse_end] : ""; | &buf[start_pos + parse_end] : ""; | ||||
fflush(stdout); | fflush(stdout); | ||||
int fail_offset = total_read - ret + start_pos + parse_end; | |||||
int fail_offset = (int)(total_read - ret + start_pos + parse_end); | |||||
fprintf(stderr, "Failed at offset %d: %s %c\n", fail_offset, | fprintf(stderr, "Failed at offset %d: %s %c\n", fail_offset, | ||||
json_tokener_error_desc(jerr), aterr[0]); | json_tokener_error_desc(jerr), aterr[0]); | ||||
json_tokener_free(tok); | json_tokener_free(tok); | ||||
@@ -201,7 +201,7 @@ static int json_escape_str(struct printbuf *pb, const char *str, size_t len, int | |||||
} | } | ||||
if (pos > start_offset) | if (pos > start_offset) | ||||
printbuf_memappend(pb, str + start_offset, pos - start_offset); | |||||
printbuf_memappend(pb, str + start_offset, (int)(pos - start_offset)); | |||||
if (c == '\b') | if (c == '\b') | ||||
printbuf_memappend(pb, "\\b", 2); | printbuf_memappend(pb, "\\b", 2); | ||||
@@ -228,7 +228,7 @@ static int json_escape_str(struct printbuf *pb, const char *str, size_t len, int | |||||
char sbuf[7]; | char sbuf[7]; | ||||
if (pos > start_offset) | if (pos > start_offset) | ||||
printbuf_memappend(pb, str + start_offset, | printbuf_memappend(pb, str + start_offset, | ||||
pos - start_offset); | |||||
(int)(pos - start_offset)); | |||||
snprintf(sbuf, sizeof(sbuf), "\\u00%c%c", json_hex_chars[c >> 4], | snprintf(sbuf, sizeof(sbuf), "\\u00%c%c", json_hex_chars[c >> 4], | ||||
json_hex_chars[c & 0xf]); | json_hex_chars[c & 0xf]); | ||||
printbuf_memappend_fast(pb, sbuf, (int)sizeof(sbuf) - 1); | printbuf_memappend_fast(pb, sbuf, (int)sizeof(sbuf) - 1); | ||||
@@ -239,7 +239,7 @@ static int json_escape_str(struct printbuf *pb, const char *str, size_t len, int | |||||
} | } | ||||
} | } | ||||
if (pos > start_offset) | if (pos > start_offset) | ||||
printbuf_memappend(pb, str + start_offset, pos - start_offset); | |||||
printbuf_memappend(pb, str + start_offset, (int)(pos - start_offset)); | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -679,7 +679,7 @@ static int json_object_int_to_json_string(struct json_object *jso, struct printb | |||||
snprintf(sbuf, sizeof(sbuf), "%" PRId64, JC_INT(jso)->cint.c_int64); | snprintf(sbuf, sizeof(sbuf), "%" PRId64, JC_INT(jso)->cint.c_int64); | ||||
else | else | ||||
snprintf(sbuf, sizeof(sbuf), "%" PRIu64, JC_INT(jso)->cint.c_uint64); | snprintf(sbuf, sizeof(sbuf), "%" PRIu64, JC_INT(jso)->cint.c_uint64); | ||||
return printbuf_memappend(pb, sbuf, strlen(sbuf)); | |||||
return printbuf_memappend(pb, sbuf, (int)strlen(sbuf)); | |||||
} | } | ||||
struct json_object *json_object_new_int(int32_t i) | struct json_object *json_object_new_int(int32_t i) | ||||
@@ -1062,7 +1062,7 @@ static int json_object_double_to_json_string_format(struct json_object *jso, str | |||||
/* drop trailing zeroes */ | /* drop trailing zeroes */ | ||||
if (*p != 0) | if (*p != 0) | ||||
*(++p) = 0; | *(++p) = 0; | ||||
size = p - buf; | |||||
size = (int)(p - buf); | |||||
} | } | ||||
} | } | ||||
// although unlikely, snprintf can fail | // although unlikely, snprintf can fail | ||||
@@ -1133,7 +1133,7 @@ static int _json_object_userdata_to_json_string(struct json_object *jso, struct | |||||
int json_object_userdata_to_json_string(struct json_object *jso, struct printbuf *pb, int level, | int json_object_userdata_to_json_string(struct json_object *jso, struct printbuf *pb, int level, | ||||
int flags) | int flags) | ||||
{ | { | ||||
int userdata_len = strlen((const char *)jso->_userdata); | |||||
int userdata_len = (int)strlen((const char *)jso->_userdata); | |||||
printbuf_memappend(pb, (const char *)jso->_userdata, userdata_len); | printbuf_memappend(pb, (const char *)jso->_userdata, userdata_len); | ||||
return userdata_len; | return userdata_len; | ||||
} | } | ||||
@@ -1301,7 +1301,7 @@ int json_object_get_string_len(const struct json_object *jso) | |||||
return 0; | return 0; | ||||
switch (jso->o_type) | switch (jso->o_type) | ||||
{ | { | ||||
case json_type_string: return _json_object_get_string_len(JC_STRING_C(jso)); | |||||
case json_type_string: return (int)_json_object_get_string_len(JC_STRING_C(jso)); | |||||
default: return 0; | default: return 0; | ||||
} | } | ||||
} | } | ||||
@@ -1673,7 +1673,7 @@ int json_c_shallow_copy_default(json_object *src, json_object *parent, const cha | |||||
case json_type_string: | case json_type_string: | ||||
*dst = json_object_new_string_len(get_string_component(src), | *dst = json_object_new_string_len(get_string_component(src), | ||||
_json_object_get_string_len(JC_STRING(src))); | |||||
(int)_json_object_get_string_len(JC_STRING(src))); | |||||
break; | break; | ||||
case json_type_object: *dst = json_object_new_object(); break; | case json_type_object: *dst = json_object_new_object(); break; | ||||
@@ -29,8 +29,8 @@ | |||||
static void string_replace_all_occurrences_with_char(char *s, const char *occur, char repl_char) | static void string_replace_all_occurrences_with_char(char *s, const char *occur, char repl_char) | ||||
{ | { | ||||
int slen = strlen(s); | |||||
int skip = strlen(occur) - 1; /* length of the occurrence, minus the char we're replacing */ | |||||
size_t slen = strlen(s); | |||||
int skip = (int)strlen(occur) - 1; /* length of the occurrence, minus the char we're replacing */ | |||||
char *p = s; | char *p = s; | ||||
while ((p = strstr(p, occur))) | while ((p = strstr(p, occur))) | ||||
{ | { | ||||
@@ -43,7 +43,7 @@ static void string_replace_all_occurrences_with_char(char *s, const char *occur, | |||||
static int is_valid_index(struct json_object *jo, const char *path, int32_t *idx) | static int is_valid_index(struct json_object *jo, const char *path, int32_t *idx) | ||||
{ | { | ||||
int i, len = strlen(path); | |||||
int i, len = (int)strlen(path); | |||||
/* this code-path optimizes a bit, for when we reference the 0-9 index range | /* this code-path optimizes a bit, for when we reference the 0-9 index range | ||||
* in a JSON array and because leading zeros not allowed | * in a JSON array and because leading zeros not allowed | ||||
*/ | */ | ||||
@@ -73,14 +73,14 @@ static int is_valid_index(struct json_object *jo, const char *path, int32_t *idx | |||||
} | } | ||||
} | } | ||||
*idx = strtol(path, NULL, 10); | |||||
*idx = (int)strtol(path, NULL, 10); | |||||
if (*idx < 0) | if (*idx < 0) | ||||
{ | { | ||||
errno = EINVAL; | errno = EINVAL; | ||||
return 0; | return 0; | ||||
} | } | ||||
check_oob: | check_oob: | ||||
len = json_object_array_length(jo); | |||||
len = (int)json_object_array_length(jo); | |||||
if (*idx >= len) | if (*idx >= len) | ||||
{ | { | ||||
errno = ENOENT; | errno = ENOENT; | ||||
@@ -560,11 +560,11 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char * | |||||
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) | if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) | ||||
{ | { | ||||
printbuf_memappend_fast(tok->pb, case_start, | printbuf_memappend_fast(tok->pb, case_start, | ||||
str - case_start); | |||||
(int)(str - case_start)); | |||||
goto out; | goto out; | ||||
} | } | ||||
} | } | ||||
printbuf_memappend_fast(tok->pb, case_start, 1 + str - case_start); | |||||
printbuf_memappend_fast(tok->pb, case_start, 1 + (int)(str - case_start)); | |||||
state = json_tokener_state_comment_end; | state = json_tokener_state_comment_end; | ||||
} | } | ||||
break; | break; | ||||
@@ -578,11 +578,11 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char * | |||||
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) | if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) | ||||
{ | { | ||||
printbuf_memappend_fast(tok->pb, case_start, | printbuf_memappend_fast(tok->pb, case_start, | ||||
str - case_start); | |||||
(int)(str - case_start)); | |||||
goto out; | goto out; | ||||
} | } | ||||
} | } | ||||
printbuf_memappend_fast(tok->pb, case_start, str - case_start); | |||||
printbuf_memappend_fast(tok->pb, case_start, (int)(str - case_start)); | |||||
MC_DEBUG("json_tokener_comment: %s\n", tok->pb->buf); | MC_DEBUG("json_tokener_comment: %s\n", tok->pb->buf); | ||||
state = json_tokener_state_eatws; | state = json_tokener_state_eatws; | ||||
} | } | ||||
@@ -610,7 +610,7 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char * | |||||
if (c == tok->quote_char) | if (c == tok->quote_char) | ||||
{ | { | ||||
printbuf_memappend_fast(tok->pb, case_start, | printbuf_memappend_fast(tok->pb, case_start, | ||||
str - case_start); | |||||
(int)(str - case_start)); | |||||
current = | current = | ||||
json_object_new_string_len(tok->pb->buf, tok->pb->bpos); | json_object_new_string_len(tok->pb->buf, tok->pb->bpos); | ||||
if (current == NULL) | if (current == NULL) | ||||
@@ -622,7 +622,7 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char * | |||||
else if (c == '\\') | else if (c == '\\') | ||||
{ | { | ||||
printbuf_memappend_fast(tok->pb, case_start, | printbuf_memappend_fast(tok->pb, case_start, | ||||
str - case_start); | |||||
(int)(str - case_start)); | |||||
saved_state = json_tokener_state_string; | saved_state = json_tokener_state_string; | ||||
state = json_tokener_state_string_escape; | state = json_tokener_state_string_escape; | ||||
break; | break; | ||||
@@ -630,7 +630,7 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char * | |||||
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) | if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) | ||||
{ | { | ||||
printbuf_memappend_fast(tok->pb, case_start, | printbuf_memappend_fast(tok->pb, case_start, | ||||
str - case_start); | |||||
(int)(str - case_start)); | |||||
goto out; | goto out; | ||||
} | } | ||||
} | } | ||||
@@ -1130,7 +1130,7 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char * | |||||
if (c == tok->quote_char) | if (c == tok->quote_char) | ||||
{ | { | ||||
printbuf_memappend_fast(tok->pb, case_start, | printbuf_memappend_fast(tok->pb, case_start, | ||||
str - case_start); | |||||
(int)(str - case_start)); | |||||
obj_field_name = strdup(tok->pb->buf); | obj_field_name = strdup(tok->pb->buf); | ||||
saved_state = json_tokener_state_object_field_end; | saved_state = json_tokener_state_object_field_end; | ||||
state = json_tokener_state_eatws; | state = json_tokener_state_eatws; | ||||
@@ -1139,7 +1139,7 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char * | |||||
else if (c == '\\') | else if (c == '\\') | ||||
{ | { | ||||
printbuf_memappend_fast(tok->pb, case_start, | printbuf_memappend_fast(tok->pb, case_start, | ||||
str - case_start); | |||||
(int)(str - case_start)); | |||||
saved_state = json_tokener_state_object_field; | saved_state = json_tokener_state_object_field; | ||||
state = json_tokener_state_string_escape; | state = json_tokener_state_string_escape; | ||||
break; | break; | ||||
@@ -1147,7 +1147,7 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char * | |||||
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) | if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) | ||||
{ | { | ||||
printbuf_memappend_fast(tok->pb, case_start, | printbuf_memappend_fast(tok->pb, case_start, | ||||
str - case_start); | |||||
(int)(str - case_start)); | |||||
goto out; | goto out; | ||||
} | } | ||||
} | } | ||||
@@ -107,7 +107,7 @@ struct json_object *json_object_from_fd_ex(int fd, int in_depth) | |||||
return NULL; | return NULL; | ||||
} | } | ||||
while ((ret = read(fd, buf, JSON_FILE_BUF_SIZE)) > 0) | |||||
while ((ret = (int)read(fd, buf, JSON_FILE_BUF_SIZE)) > 0) | |||||
{ | { | ||||
if (printbuf_memappend(pb, buf, ret) < 0) | if (printbuf_memappend(pb, buf, ret) < 0) | ||||
{ | { | ||||
@@ -207,7 +207,7 @@ static int _json_object_to_fd(int fd, struct json_object *obj, int flags, const | |||||
wpos = 0; | wpos = 0; | ||||
while (wpos < wsize) | while (wpos < wsize) | ||||
{ | { | ||||
if ((ret = write(fd, json_str + wpos, wsize - wpos)) < 0) | |||||
if ((ret = (int)write(fd, json_str + wpos, wsize - wpos)) < 0) | |||||
{ | { | ||||
_json_c_set_last_err("json_object_to_fd: error writing file %s: %s\n", | _json_c_set_last_err("json_object_to_fd: error writing file %s: %s\n", | ||||
filename, strerror(errno)); | filename, strerror(errno)); | ||||
@@ -53,7 +53,7 @@ static void single_incremental_parse(const char *test_string, int clear_serializ | |||||
all_at_once_str = json_object_to_json_string(all_at_once_obj); | all_at_once_str = json_object_to_json_string(all_at_once_obj); | ||||
tok = json_tokener_new(); | tok = json_tokener_new(); | ||||
int test_string_len = strlen(test_string) + 1; // Including '\0' ! | |||||
int test_string_len = (int)strlen(test_string) + 1; // Including '\0' ! | |||||
for (ii = 0; ii < test_string_len; ii += chunksize) | for (ii = 0; ii < test_string_len; ii += chunksize) | ||||
{ | { | ||||
int len_to_parse = chunksize; | int len_to_parse = chunksize; | ||||