From cbb51719cf12c90b79846d670197b13fb2dd1590 Mon Sep 17 00:00:00 2001 From: Sylvain Miermont Date: Thu, 10 Oct 2013 14:28:45 +0200 Subject: [PATCH] Checking that fread *actually* succeeds, fix the warning bellow when compiling with -O1, -O2 or -O3. "warning: ignoring return value of 'fread', declared with attribute warn_unused_result" --- parson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parson.c b/parson.c index 14a27d5..54eae2c 100644 --- a/parson.c +++ b/parson.c @@ -500,7 +500,7 @@ JSON_Value * json_parse_file(const char *filename) { rewind(fp); file_contents = (char*)parson_malloc(sizeof(char) * (file_size + 1)); if (!file_contents) { fclose(fp); return NULL; } - fread(file_contents, file_size, 1, fp); + if (fread(file_contents, file_size, 1, fp) < 1) { fclose(fp); return NULL; } fclose(fp); file_contents[file_size] = '\0'; output_value = json_parse_string(file_contents);