Skip to content

Commit 7a4a982

Browse files
committed
More peer review fixes
1 parent 997583f commit 7a4a982

File tree

5 files changed

+29
-16
lines changed

5 files changed

+29
-16
lines changed

test-app/syscalls.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ extern void uart_write(const char *buf, unsigned int sz);
9090

9191
int _write(int file, char *ptr, int len)
9292
{
93-
int i;
94-
9593
/* Write to UART for stdout/stderr */
9694
if (file == 1 || file == 2) {
9795
uart_write(ptr, len);

test-app/wolfcrypt_support.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,19 @@ unsigned long my_time(unsigned long* timer)
7676
*/
7777
double current_time(int reset)
7878
{
79-
(void)reset;
80-
8179
#if defined(WOLFCRYPT_SECURE_MODE)
8280
return wolfBoot_nsc_current_time(reset);
8381
#elif defined(TARGET_va416x0)
82+
(void)reset;
8483
/* Use Vorago SDK SysTick-based millisecond counter */
8584
return (double)HAL_time_ms / 1000.0;
8685
#else
8786
/* Simple counter-based timing */
88-
double timeNow = (double)tick_counter;
89-
return timeNow;
87+
if (reset)
88+
tick_counter = 0;
89+
else
90+
tick_counter++;
91+
return (double)tick_counter;
9092
#endif
9193
}
9294
#endif /* WOLFCRYPT_BENCHMARK */

tools/keytools/sign.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,7 @@ static int make_header_ex(int is_diff, uint8_t *pubkey, uint32_t pubkey_sz,
17441744
{
17451745
const char *env_psize = getenv("WOLFBOOT_PARTITION_SIZE");
17461746
const char *env_ssize = getenv("WOLFBOOT_SECTOR_SIZE");
1747-
if (env_psize) {
1747+
if (env_psize && *env_psize) {
17481748
char *endptr;
17491749
unsigned long tmp;
17501750
uint32_t partition_sz, sector_sz = 0;
@@ -1779,10 +1779,17 @@ static int make_header_ex(int is_diff, uint8_t *pubkey, uint32_t pubkey_sz,
17791779
uint32_t max_img_sz = (sector_sz < partition_sz) ?
17801780
(partition_sz - sector_sz) : partition_sz;
17811781
if (total_img_sz > max_img_sz) {
1782-
printf("Error: Image size %u (header %u + firmware %u) "
1783-
"exceeds max %u (partition %u - sector %u)\n",
1784-
total_img_sz, CMD.header_sz, image_sz,
1785-
max_img_sz, partition_sz, sector_sz);
1782+
if (sector_sz < partition_sz) {
1783+
printf("Error: Image size %u (header %u + firmware %u) "
1784+
"exceeds max %u (partition %u - sector %u)\n",
1785+
total_img_sz, CMD.header_sz, image_sz,
1786+
max_img_sz, partition_sz, sector_sz);
1787+
} else {
1788+
printf("Error: Image size %u (header %u + firmware %u) "
1789+
"exceeds max %u (partition %u)\n",
1790+
total_img_sz, CMD.header_sz, image_sz,
1791+
max_img_sz, partition_sz);
1792+
}
17861793
goto failure;
17871794
}
17881795
}

tools/keytools/sign.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,10 +724,16 @@ def make_header(image_file, fw_version, extra_fields=[]):
724724
else:
725725
max_img_sz = WOLFBOOT_PARTITION_SIZE
726726
if total_img_sz > max_img_sz:
727-
print("Error: Image size %d (header %d + firmware %d) "
728-
"exceeds max %d (partition %d - sector %d)" %
729-
(total_img_sz, WOLFBOOT_HEADER_SIZE, img_size,
730-
max_img_sz, WOLFBOOT_PARTITION_SIZE, WOLFBOOT_SECTOR_SIZE))
727+
if WOLFBOOT_SECTOR_SIZE < WOLFBOOT_PARTITION_SIZE:
728+
print("Error: Image size %d (header %d + firmware %d) "
729+
"exceeds max %d (partition %d - sector %d)" %
730+
(total_img_sz, WOLFBOOT_HEADER_SIZE, img_size,
731+
max_img_sz, WOLFBOOT_PARTITION_SIZE, WOLFBOOT_SECTOR_SIZE))
732+
else:
733+
print("Error: Image size %d (header %d + firmware %d) "
734+
"exceeds max %d (partition %d)" %
735+
(total_img_sz, WOLFBOOT_HEADER_SIZE, img_size,
736+
max_img_sz, WOLFBOOT_PARTITION_SIZE))
731737
sys.exit(1)
732738

733739
if (encrypt):

tools/test.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ test-all: clean
11101110
test-size-all:
11111111
make test-size SIGN=NONE LIMIT=5040 NO_ARM_ASM=1
11121112
make keysclean
1113-
make test-size SIGN=ED25519 LIMIT=11696 NO_ARM_ASM=1
1113+
make test-size SIGN=ED25519 LIMIT=11700 NO_ARM_ASM=1
11141114
make keysclean
11151115
make test-size SIGN=ECC256 LIMIT=18944 NO_ARM_ASM=1
11161116
make clean

0 commit comments

Comments
 (0)