From 6663ebb70a275785e2c1fe9830dc53cb10088237 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sun, 5 Jan 2014 11:22:43 +0000 Subject: [PATCH] fix some warnings --- src/jconf.c | 3 ++- src/json.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/jconf.c b/src/jconf.c index 470bc8cf..2a678458 100644 --- a/src/jconf.c +++ b/src/jconf.c @@ -76,7 +76,8 @@ jconf_t *read_jconf(const char* file) buf = malloc(pos + 1); if (buf == NULL) FATAL("No enough memory."); - fread(buf, pos, 1, f); + int err = fread(buf, pos, 1, f); + if (err) FATAL("Failed to read the config file."); fclose(f); buf[pos] = '\0'; // end of string diff --git a/src/json.c b/src/json.c index bfe6bd36..052e6db5 100644 --- a/src/json.c +++ b/src/json.c @@ -205,8 +205,9 @@ json_value * json_parse_ex (json_settings * settings, json_value * top, * root, * alloc = 0; json_state state = { 0 }; long flags; - long num_digits, num_e; - json_int_t num_fraction; + long num_digits = 0; + long num_e = 0; + json_int_t num_fraction = 0; error[0] = '\0'; end = (json + length); @@ -229,8 +230,8 @@ json_value * json_parse_ex (json_settings * settings, { json_uchar uchar; unsigned char uc_b1, uc_b2, uc_b3, uc_b4; - json_char * string; - unsigned int string_length; + json_char * string = NULL; + unsigned int string_length = 0; top = root = 0; flags = flag_seek_value;