Simplify fgets() error handling to use one goto

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This commit is contained in:
Patrick McCarty
2016-04-04 11:42:25 -07:00
parent afa836b9d5
commit ea14cf04df
+2 -4
View File
@@ -90,12 +90,10 @@ static int set_default_value(char **global, const char *path)
if (fgets(line, LINE_MAX, file) == NULL) {
if (ferror(file)) {
printf("Error: Unable to read data from %s\n", rel_path);
goto fail;
}
if (feof(file)) {
} else if (feof(file)) {
printf("Error: Contents of %s are empty\n", rel_path);
goto fail;
}
goto fail;
}
/* remove newline if present */