From 4c4ca66c31bf757b7cd9718c02c4e562fd12c81b Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Sat, 15 Feb 2014 18:07:29 -0500 Subject: [PATCH] Dont exit in case of hexfile reading failure --- src/common/hexfile.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/common/hexfile.c b/src/common/hexfile.c index c9c7de3..ee0c745 100644 --- a/src/common/hexfile.c +++ b/src/common/hexfile.c @@ -108,14 +108,18 @@ hexfile_load(const char *filename) log_debug("LoadHexFile"); - if (filename == NULL) - log_fail("No file specified"); + if (filename == NULL) { + log_err("No file specified"); + return false; + } /* Trying to open the file. */ fp = fopen(filename, "r"); - if (fp == NULL) - log_fail("Error opening hex file <%s>: %s", filename, - strerror(errno)); + if (fp == NULL) { + log_err("Error opening hex file <%s>: %s", filename, + strerror(errno)); + return false; + } /* Reading one line of data from the hex file. */ /* char *fgets(char *s, int size, FILE *stream); @@ -183,11 +187,12 @@ hexfile_load(const char *filename) close_file: status = fclose(fp); - if (status != EXIT_SUCCESS) - log_fail("Error closing hex file"); - - if (!valid) + if (status != EXIT_SUCCESS) { + log_err("Error closing hex file"); + valid = false; + } else if (!valid) { log_err("Error parsing hex file"); + } return valid; } -- 2.20.1