diff options
author | Jani Nikula <jani.nikula@intel.com> | 2016-05-12 15:35:37 +0300 |
---|---|---|
committer | Jani Nikula <jani.nikula@intel.com> | 2016-05-13 16:51:30 +0300 |
commit | 1dd3ff00148776961b20c6970916181b8482ae41 (patch) | |
tree | 00b62b6a38b9db702f36cc4357982f59e37a39cc /tools | |
parent | 4daac359fd896ac29007aba2659c34e88dfcbcdd (diff) |
tools/intel_bios_reader: print errors to stderr, return EXIT_FAILURE
Be consistent with exit status and printing errors to stderr.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/intel_bios_reader.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c index 59a90e23..4c4ab666 100644 --- a/tools/intel_bios_reader.c +++ b/tools/intel_bios_reader.c @@ -101,7 +101,7 @@ static struct bdb_block *find_section(struct context *context, int section_id) block = malloc(sizeof(*block)); if (!block) { fprintf(stderr, "out of memory\n"); - exit(-1); + exit(EXIT_FAILURE); } /* walk the sections looking for section_id */ @@ -1551,14 +1551,15 @@ int main(int argc, char **argv) fd = open(filename, O_RDONLY); if (fd == -1) { - printf("Couldn't open \"%s\": %s\n", filename, strerror(errno)); - return 1; + fprintf(stderr, "Couldn't open \"%s\": %s\n", + filename, strerror(errno)); + return EXIT_FAILURE; } if (stat(filename, &finfo)) { - printf("failed to stat \"%s\": %s\n", filename, - strerror(errno)); - return 1; + fprintf(stderr, "Failed to stat \"%s\": %s\n", + filename, strerror(errno)); + return EXIT_FAILURE; } size = finfo.st_size; @@ -1568,9 +1569,9 @@ int main(int argc, char **argv) VBIOS = malloc (size); while ((ret = read(fd, VBIOS + len, size - len))) { if (ret < 0) { - printf("failed to read \"%s\": %s\n", filename, - strerror(errno)); - return 1; + fprintf(stderr, "Failed to read \"%s\": %s\n", + filename, strerror(errno)); + return EXIT_FAILURE; } len += ret; @@ -1582,8 +1583,9 @@ int main(int argc, char **argv) } else { VBIOS = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); if (VBIOS == MAP_FAILED) { - printf("failed to map \"%s\": %s\n", filename, strerror(errno)); - return 1; + fprintf(stderr, "Failed to map \"%s\": %s\n", + filename, strerror(errno)); + return EXIT_FAILURE; } } @@ -1597,14 +1599,14 @@ int main(int argc, char **argv) } if (!vbt) { - printf("VBT signature missing\n"); - return 1; + fprintf(stderr, "VBT signature missing\n"); + return EXIT_FAILURE; } bdb_off = vbt_off + vbt->bdb_offset; if (bdb_off >= size - sizeof(struct bdb_header)) { - printf("Invalid VBT found, BDB points beyond end of data block\n"); - return 1; + fprintf(stderr, "Invalid VBT found, BDB points beyond end of data block\n"); + return EXIT_FAILURE; } context.vbt = vbt; |