From ea14cf04df79b424c68bee0b6330825744eb0e5d Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Mon, 4 Apr 2016 09:23:52 -0700 Subject: [PATCH] Simplify fgets() error handling to use one goto Signed-off-by: Patrick McCarty --- src/globals.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/globals.c b/src/globals.c index 4c05df3a..90b1b2d0 100644 --- a/src/globals.c +++ b/src/globals.c @@ -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 */