From: Hugo Villeneuve Date: Sat, 15 Feb 2014 23:07:29 +0000 (-0500) Subject: Dont exit in case of hexfile reading failure X-Git-Tag: v2.0.1~5 X-Git-Url: http://gitweb.hugovil.com/?p=emu8051.git;a=commitdiff_plain;h=4c4ca66c31bf757b7cd9718c02c4e562fd12c81b Dont exit in case of hexfile reading failure --- 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; }