mirror of
https://github.com/kgabis/parson.git
synced 2025-01-28 06:32:55 +08:00
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"
This commit is contained in:
parent
a024f1197c
commit
cbb51719cf
2
parson.c
2
parson.c
@ -500,7 +500,7 @@ JSON_Value * json_parse_file(const char *filename) {
|
|||||||
rewind(fp);
|
rewind(fp);
|
||||||
file_contents = (char*)parson_malloc(sizeof(char) * (file_size + 1));
|
file_contents = (char*)parson_malloc(sizeof(char) * (file_size + 1));
|
||||||
if (!file_contents) { fclose(fp); return NULL; }
|
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);
|
fclose(fp);
|
||||||
file_contents[file_size] = '\0';
|
file_contents[file_size] = '\0';
|
||||||
output_value = json_parse_string(file_contents);
|
output_value = json_parse_string(file_contents);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user