@@ -87,7 +87,7 @@ static void json_object_fini(void) { | |||
/* string escaping */ | |||
static int json_escape_str(struct printbuf *pb, char *str, int len) | |||
static int json_escape_str(struct printbuf *pb, char *str, size_t len) | |||
{ | |||
int pos = 0, start_offset = 0; | |||
unsigned char c; | |||
@@ -290,7 +290,7 @@ static void indent(struct printbuf *pb, int level, int flags) | |||
/* json_object_object */ | |||
static int json_object_object_to_json_string(struct json_object* jso, | |||
static long long json_object_object_to_json_string(struct json_object* jso, | |||
struct printbuf *pb, | |||
int level, | |||
int flags) | |||
@@ -429,7 +429,7 @@ void json_object_object_del(struct json_object* jso, const char *key) | |||
/* json_object_boolean */ | |||
static int json_object_boolean_to_json_string(struct json_object* jso, | |||
static long long json_object_boolean_to_json_string(struct json_object* jso, | |||
struct printbuf *pb, | |||
int level, | |||
int flags) | |||
@@ -467,7 +467,7 @@ json_bool json_object_get_boolean(struct json_object *jso) | |||
/* json_object_int */ | |||
static int json_object_int_to_json_string(struct json_object* jso, | |||
static long long json_object_int_to_json_string(struct json_object* jso, | |||
struct printbuf *pb, | |||
int level, | |||
int flags) | |||
@@ -554,13 +554,13 @@ int64_t json_object_get_int64(struct json_object *jso) | |||
/* json_object_double */ | |||
static int json_object_double_to_json_string(struct json_object* jso, | |||
static long long json_object_double_to_json_string(struct json_object* jso, | |||
struct printbuf *pb, | |||
int level, | |||
int flags) | |||
{ | |||
char buf[128], *p, *q; | |||
int size; | |||
long long size; | |||
size = snprintf(buf, 128, "%f", jso->o.c_double); | |||
p = strchr(buf, ','); | |||
@@ -614,7 +614,7 @@ double json_object_get_double(struct json_object *jso) | |||
/* json_object_string */ | |||
static int json_object_string_to_json_string(struct json_object* jso, | |||
static long long json_object_string_to_json_string(struct json_object* jso, | |||
struct printbuf *pb, | |||
int level, | |||
int flags) | |||
@@ -666,7 +666,7 @@ const char* json_object_get_string(struct json_object *jso) | |||
} | |||
} | |||
int json_object_get_string_len(struct json_object *jso) { | |||
size_t json_object_get_string_len(struct json_object *jso) { | |||
if(!jso) return 0; | |||
switch(jso->o_type) { | |||
case json_type_string: | |||
@@ -679,7 +679,7 @@ int json_object_get_string_len(struct json_object *jso) { | |||
/* json_object_array */ | |||
static int json_object_array_to_json_string(struct json_object* jso, | |||
static long long json_object_array_to_json_string(struct json_object* jso, | |||
struct printbuf *pb, | |||
int level, | |||
int flags) | |||
@@ -82,7 +82,7 @@ typedef void (json_object_delete_fn)(struct json_object *jso, void *userdata); | |||
/** | |||
* Type of a custom serialization function. See json_object_set_serializer. | |||
*/ | |||
typedef int (json_object_to_json_string_fn)(struct json_object *jso, | |||
typedef long long (json_object_to_json_string_fn)(struct json_object *jso, | |||
struct printbuf *pb, | |||
int level, | |||
int flags); | |||
@@ -553,7 +553,7 @@ extern const char* json_object_get_string(struct json_object *obj); | |||
* @param obj the json_object instance | |||
* @returns int | |||
*/ | |||
extern int json_object_get_string_len(struct json_object *obj); | |||
extern size_t json_object_get_string_len(struct json_object *obj); | |||
#ifdef __cplusplus | |||
} | |||
@@ -33,7 +33,7 @@ struct json_object | |||
struct array_list *c_array; | |||
struct { | |||
char *str; | |||
int len; | |||
size_t len; | |||
} c_string; | |||
} o; | |||
json_object_delete_fn *_user_delete; | |||
@@ -70,7 +70,8 @@ struct json_object* json_object_from_file(const char *filename) | |||
struct printbuf *pb; | |||
struct json_object *obj; | |||
char buf[JSON_FILE_BUF_SIZE]; | |||
int fd, ret; | |||
int fd; | |||
ssize_t ret; | |||
if((fd = open(filename, O_RDONLY)) < 0) { | |||
MC_ERROR("json_object_from_file: error reading file %s: %s\n", | |||
@@ -102,7 +103,8 @@ struct json_object* json_object_from_file(const char *filename) | |||
int json_object_to_file_ext(char *filename, struct json_object *obj, int flags) | |||
{ | |||
const char *json_str; | |||
int fd, ret; | |||
int fd; | |||
ssize_t ret; | |||
unsigned int wpos, wsize; | |||
if(!obj) { | |||
@@ -215,7 +217,7 @@ int json_parse_int64(const char *buf, int64_t *retval) | |||
char buf_cmp[100]; | |||
char *buf_cmp_start = buf_cmp; | |||
int recheck_has_neg = 0; | |||
int buf_cmp_len; | |||
size_t buf_cmp_len; | |||
// Skip leading zeros, but keep at least one digit | |||
while (buf_sig_digits[0] == '0' && buf_sig_digits[1] != '\0') | |||
@@ -29,7 +29,7 @@ | |||
#include "debug.h" | |||
#include "printbuf.h" | |||
static int printbuf_extend(struct printbuf *p, int min_size); | |||
static int printbuf_extend(struct printbuf *p, size_t min_size); | |||
struct printbuf* printbuf_new(void) | |||
{ | |||
@@ -55,10 +55,10 @@ struct printbuf* printbuf_new(void) | |||
* Note: this does not check the available space! The caller | |||
* is responsible for performing those calculations. | |||
*/ | |||
static int printbuf_extend(struct printbuf *p, int min_size) | |||
static int printbuf_extend(struct printbuf *p, size_t min_size) | |||
{ | |||
char *t; | |||
int new_size; | |||
size_t new_size; | |||
if (p->size >= min_size) | |||
return 0; | |||
@@ -76,7 +76,7 @@ static int printbuf_extend(struct printbuf *p, int min_size) | |||
return 0; | |||
} | |||
int printbuf_memappend(struct printbuf *p, const char *buf, int size) | |||
size_t printbuf_memappend(struct printbuf *p, const char *buf, size_t size) | |||
{ | |||
if (p->size <= p->bpos + size + 1) { | |||
if (printbuf_extend(p, p->bpos + size + 1) < 0) | |||
@@ -23,7 +23,7 @@ extern "C" { | |||
struct printbuf { | |||
char *buf; | |||
int bpos; | |||
int size; | |||
size_t size; | |||
}; | |||
extern struct printbuf* | |||
@@ -36,8 +36,8 @@ printbuf_new(void); | |||
* Your code should not use printbuf_memappend directly--use | |||
* printbuf_memappend_fast instead. | |||
*/ | |||
extern int | |||
printbuf_memappend(struct printbuf *p, const char *buf, int size); | |||
extern size_t | |||
printbuf_memappend(struct printbuf *p, const char *buf, size_t size); | |||
#define printbuf_memappend_fast(p, bufptr, bufsize) \ | |||
do { \ | |||