summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Buren <braewoods+rb@braewoods.net>2021-06-17 15:30:51 +0000
committerJames Buren <braewoods+rb@braewoods.net>2021-06-17 15:30:51 +0000
commit3831051c478d18f19978529261761802f3c9eebc (patch)
tree118a66cc18705a27e6bcf7af5eb13f1dffd1c957
parent2ed4bf8a433e7c6ab4c8cefe982626963ec759e3 (diff)
downloadrockbox-3831051c47.tar.gz
rockbox-3831051c47.zip
mknkboot: optimize verifyfirm
The checksum only needs to be calculated once. A small oversight on my initial implementation. Change-Id: Ie23faf36f5add7ed7f146769b604dbd8204c2605
-rw-r--r--utils/MTP/beastpatcher/mknkboot.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/utils/MTP/beastpatcher/mknkboot.c b/utils/MTP/beastpatcher/mknkboot.c
index 9efc5d7595..29de27217d 100644
--- a/utils/MTP/beastpatcher/mknkboot.c
+++ b/utils/MTP/beastpatcher/mknkboot.c
@@ -158,16 +158,16 @@ static off_t filesize(int fd) {
int verifyfirm(const struct filebuf* firmdata)
{
- for(int i = 0; firmtable[i].version; i++)
- {
- md5_context ctx;
- uint8_t sum[16];
+ md5_context ctx;
+ uint8_t sum[16];
- md5_starts(&ctx);
- md5_update(&ctx, firmdata->buf, firmdata->len);
- md5_finish(&ctx, sum);
+ md5_starts(&ctx);
+ md5_update(&ctx, firmdata->buf, firmdata->len);
+ md5_finish(&ctx, sum);
- if(memcmp(firmtable[i].sum, sum, 16) == 0)
+ for(int i = 0; firmtable[i].version; i++)
+ {
+ if(memcmp(firmtable[i].sum, sum, 16) == 0)
{
fprintf(stderr, "[INFO] Firmware file version %d.%d\n",
firmtable[i].version >> 8, firmtable[i].version & 0xff);