treewide: Make carray arrays const and NULL-terminated

This allows the compiler to generate significantly better code, because
it does not have to maintain either the loop counter or loop limit. Plus
there are half as many symbols to relocate. This also simplifies passing
carray arrays to helper functions.

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Samuel Holland
2024-11-11 14:02:45 -08:00
committed by Anup Patel
parent 23ef9c5f00
commit df1c100001
12 changed files with 26 additions and 38 deletions

View File

@@ -11,8 +11,7 @@
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_RESET "\x1b[0m"
extern struct sbiunit_test_suite *sbi_unit_tests[];
extern unsigned long sbi_unit_tests_size;
extern struct sbiunit_test_suite *const sbi_unit_tests[];
static void run_test_suite(struct sbiunit_test_suite *suite)
{
@@ -48,6 +47,6 @@ void run_all_tests(void)
sbi_printf("\n# Running SBIUNIT tests #\n");
for (i = 0; i < sbi_unit_tests_size; i++)
for (i = 0; sbi_unit_tests[i]; i++)
run_test_suite(sbi_unit_tests[i]);
}