forked from len0rd/rockbox
mkimxboot: code simplification
Change-Id: Ic16334c262ee5bce3575c306440f7e1de2b247f9
This commit is contained in:
parent
f285a0f28b
commit
da8ebcec2f
1 changed files with 5 additions and 18 deletions
|
|
@ -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 */
|
/* compute MD5 of a file */
|
||||||
static enum imx_error_t compute_md5sum(const char *file, uint8_t file_md5sum[16])
|
static enum imx_error_t compute_md5sum(const char *file, uint8_t file_md5sum[16])
|
||||||
{
|
{
|
||||||
FILE *f = fopen(file, "rb");
|
void *buf;
|
||||||
if(f == NULL)
|
size_t sz;
|
||||||
{
|
enum imx_error_t err = read_file(file, &buf, &sz);
|
||||||
printf("[ERR] Cannot open input file\n");
|
if(err != IMX_SUCCESS)
|
||||||
return IMX_OPEN_ERROR;
|
return err;
|
||||||
}
|
|
||||||
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);
|
|
||||||
compute_md5sum_buf(buf, sz, file_md5sum);
|
compute_md5sum_buf(buf, sz, file_md5sum);
|
||||||
free(buf);
|
free(buf);
|
||||||
return IMX_SUCCESS;
|
return IMX_SUCCESS;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue