From 5a838851ed211f56ebbe705b890a134e18391456 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Wed, 17 Jun 2026 11:50:40 -0400 Subject: [PATCH] utils: More warning fixes Change-Id: Ie7af33ab0e3ac43f93a4cf2df50ddac10243b9f7 --- utils/rk27utils/rkboottool/rkboottool.c | 55 ++++++++++++------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/utils/rk27utils/rkboottool/rkboottool.c b/utils/rk27utils/rkboottool/rkboottool.c index 8858d37478..e2bb787c65 100644 --- a/utils/rk27utils/rkboottool/rkboottool.c +++ b/utils/rk27utils/rkboottool/rkboottool.c @@ -101,40 +101,40 @@ static void *binary_extract(FILE *fp, uint32_t offset, uint32_t len, int descram if ((fp == NULL) || len == 0) return NULL; - /* allocate buff */ - if ((buff = malloc(len)) == NULL) - return NULL; + /* allocate buff */ + if ((buff = malloc(len)) == NULL) + return NULL; - /* seek to the begining of the data */ - fseek(fp, offset, SEEK_SET); + /* seek to the begining of the data */ + fseek(fp, offset, SEEK_SET); - /* read into the buffer */ - ret = fread(buff, 1, len, fp); + /* read into the buffer */ + ret = fread(buff, 1, len, fp); - if (ret != len) + if (ret != len) + { + free(buff); + return NULL; + } + + /* descramble */ + if ( descramble ) + { + buff_ptr = buff; + if (encode_mode == PAGE_ENC) { - free(buff); - return NULL; - } - - /* descramble */ - if ( descramble ) - { - buff_ptr = buff; - if (encode_mode == PAGE_ENC) + while (len >= 0x200) { - while (len >= 0x200) - { - encode_page((uint8_t *)buff_ptr, - (uint8_t *)buff_ptr, - 0x200); + encode_page((uint8_t *)buff_ptr, + (uint8_t *)buff_ptr, + 0x200); - buff_ptr += 0x200; - len -= 0x200; - } + buff_ptr += 0x200; + len -= 0x200; } - encode_page((uint8_t *)buff_ptr, (uint8_t *)buff_ptr, len); } + encode_page((uint8_t *)buff_ptr, (uint8_t *)buff_ptr, len); + } return buff; } @@ -270,7 +270,7 @@ int main (int argc, char **argv) } fwrite(buff, 1, rkboot_info.s1_len, fp_out); - + fprintf(stderr, "[info]: extracted rkboot_s1.bin file\n"); free(buff); fclose(fp_out); @@ -358,4 +358,3 @@ int main (int argc, char **argv) fclose(fp_in); return 0; } -