summaryrefslogtreecommitdiffstats
path: root/rbutil/mkimxboot
diff options
context:
space:
mode:
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;