diff options
author | Stefan Reinauer <stepan@coresystems.de> | 2010-06-24 13:37:59 +0000 |
---|---|---|
committer | Stefan Reinauer <stepan@openbios.org> | 2010-06-24 13:37:59 +0000 |
commit | 9bb0438535d29329f6a01a136caa2f2ad79fdceb (patch) | |
tree | ed44ef0c6bd231abd1252487f04f66b1ff1079bf /util/cbfstool/common.c | |
parent | 980a69b8c20ad975553980ccb320bf25ff7c0b16 (diff) | |
download | coreboot-9bb0438535d29329f6a01a136caa2f2ad79fdceb.tar.xz |
fix return value checks of cbfstool's writerom
Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5644 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/cbfstool/common.c')
-rw-r--r-- | util/cbfstool/common.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c index b071864b5c..8478c5a492 100644 --- a/util/cbfstool/common.c +++ b/util/cbfstool/common.c @@ -90,11 +90,23 @@ void *loadrom(const char *filename) return romarea; } -void writerom(const char *filename, void *start, uint32_t size) +int writerom(const char *filename, void *start, uint32_t size) { FILE *file = fopen(filename, "wb"); - fwrite(start, size, 1, file); + if (!file) { + fprintf(stderr, "Could not open '%s' for writing: ", filename); + perror(""); + return 1; + } + + if (fwrite(start, size, 1, file) != 1) { + fprintf(stderr, "Could not write to '%s': ", filename); + perror(""); + return 1; + } + fclose(file); + return 0; } int cbfs_file_header(uint32_t physaddr) |