summaryrefslogtreecommitdiff
path: root/apps/plugins/iriver_flash.c
diff options
context:
space:
mode:
authorJames Buren <braewoods+rb@braewoods.net>2020-11-21 17:58:01 +0000
committerWilliam Wilgus <me.theuser@yahoo.com>2020-11-22 05:12:04 +0000
commit6b3b4df6f64f1523b76d5f4f26c568ffc208a899 (patch)
treee3a0f2fe2562baf140655718288e92839b7474fa /apps/plugins/iriver_flash.c
parent2eb191a3f408281fde2fbd0003f2bdd6c2234970 (diff)
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
Diffstat (limited to 'apps/plugins/iriver_flash.c')
-rw-r--r--apps/plugins/iriver_flash.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/apps/plugins/iriver_flash.c b/apps/plugins/iriver_flash.c
index 9454ac63c8..152ac339ff 100644
--- a/apps/plugins/iriver_flash.c
+++ b/apps/plugins/iriver_flash.c
@@ -23,6 +23,7 @@
****************************************************************************/
#include "plugin.h"
#include "lib/helper.h"
+#include "checksum.h"
/*
* Flash commands may rely on null pointer dereferences to work correctly.
@@ -395,7 +396,6 @@ static bool load_firmware(const char* filename, enum firmware firmware,
{
uint32_t checksum;
uint8_t model[4];
- uint32_t sum;
/* subtract the header length */
fd_len -= sizeof(checksum) + sizeof(model);
@@ -418,13 +418,8 @@ static bool load_firmware(const char* filename, enum firmware firmware,
goto bail;
}
- /* calculate the checksum */
- sum = MODEL_NUMBER;
- for (off_t i = 0; i < fd_len; i++)
- sum += buffer[i];
-
/* verify the checksum */
- if (sum != checksum)
+ if (!verify_checksum(checksum, buffer, fd_len))
{
msg = "Aborting: checksum mismatch";
goto bail;