forked from len0rd/rockbox
rockbox: move firmware checksum algorithms into a common header
Before this was just implemented inline wherever it was needed. Now it is provided as 2 inline functions in a header called checksum.h. There should be no differences in actual behavior. Change-Id: I5d756cc01dc6225f5cc8b6af90911a3fc7b57cd5
This commit is contained in:
parent
2eb191a3f4
commit
6b3b4df6f6
4 changed files with 47 additions and 30 deletions
|
|
@ -24,6 +24,7 @@
|
|||
#include "system.h"
|
||||
#include "file.h"
|
||||
#include "loader_strerror.h"
|
||||
#include "checksum.h"
|
||||
|
||||
#if defined(HAVE_BOOTDATA)
|
||||
#include "bootdata.h"
|
||||
|
|
@ -129,8 +130,7 @@ static int load_firmware_filename(unsigned char* buf,
|
|||
int buffer_size)
|
||||
{
|
||||
int len;
|
||||
unsigned long chksum, sum;
|
||||
int i;
|
||||
unsigned long chksum;
|
||||
int ret;
|
||||
int fd = open(filename, O_RDONLY);
|
||||
|
||||
|
|
@ -162,14 +162,7 @@ static int load_firmware_filename(unsigned char* buf,
|
|||
goto end;
|
||||
}
|
||||
|
||||
sum = MODEL_NUMBER;
|
||||
|
||||
for(i = 0;i < len;i++)
|
||||
{
|
||||
sum += buf[i];
|
||||
}
|
||||
|
||||
if (sum != chksum)
|
||||
if (!verify_checksum(chksum, buf, len))
|
||||
{
|
||||
ret = EBAD_CHKSUM;
|
||||
goto end;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue