summaryrefslogtreecommitdiffstats
path: root/rbutil/mkimxboot
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-07-30 17:12:23 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-08-06 21:24:38 +0200
commitda8ebcec2fc82fd6b25e08568e37ac88e34e05e6 (patch)
treedc77584a4580af91f36576ee1a5f2f5ecd7ba795 /rbutil/mkimxboot
parentf285a0f28b8ca282094ab10ffc7a53d337d58a3c (diff)
downloadrockbox-da8ebcec2fc82fd6b25e08568e37ac88e34e05e6.tar.gz
rockbox-da8ebcec2fc82fd6b25e08568e37ac88e34e05e6.tar.bz2
rockbox-da8ebcec2fc82fd6b25e08568e37ac88e34e05e6.zip
mkimxboot: code simplification
Change-Id: Ic16334c262ee5bce3575c306440f7e1de2b247f9
Diffstat (limited to 'rbutil/mkimxboot')
-rw-r--r--rbutil/mkimxboot/mkimxboot.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/rbutil/mkimxboot/mkimxboot.c b/rbutil/mkimxboot/mkimxboot.c
index 5f9a1e1ed9..33516a92d6 100644
--- a/rbutil/mkimxboot/mkimxboot.c
+++ b/rbutil/mkimxboot/mkimxboot.c
@@ -532,24 +532,11 @@ static enum imx_error_t compute_md5sum_buf(void *buf, size_t sz, uint8_t file_md
/* compute MD5 of a file */
static enum imx_error_t compute_md5sum(const char *file, uint8_t file_md5sum[16])
{
- FILE *f = fopen(file, "rb");
- if(f == NULL)
- {
- printf("[ERR] Cannot open input file\n");
- return IMX_OPEN_ERROR;
- }
- fseek(f, 0, SEEK_END);
- size_t sz = ftell(f);
- fseek(f, 0, SEEK_SET);
- void *buf = xmalloc(sz);
- if(fread(buf, sz, 1, f) != 1)
- {
- fclose(f);
- free(buf);
- printf("[ERR] Cannot read file\n");
- return IMX_READ_ERROR;
- }
- fclose(f);
+ void *buf;
+ size_t sz;
+ enum imx_error_t err = read_file(file, &buf, &sz);
+ if(err != IMX_SUCCESS)
+ return err;
compute_md5sum_buf(buf, sz, file_md5sum);
free(buf);
return IMX_SUCCESS;