Skip to content

Commit c5164f3

Browse files
Andrew Boienashif
authored andcommitted
kernel: init: exclude unreachable code
LCOV/gcovr doesn't understand what CODE_UNREACHABLE means. Adding LCOV_EXCL_LINE to the macro definition unfortunately doesn't work. Exclude a bit of code which spins endlessly when multi- threading is disabled that runs after the coverage report is dumped. Signed-off-by: Andrew Boie <[email protected]>
1 parent 8e05333 commit c5164f3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kernel/init.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ static void prepare_multithreading(struct k_thread *dummy_thread)
411411

412412
}
413413

414-
static void switch_to_main_thread(void)
414+
static FUNC_NORETURN void switch_to_main_thread(void)
415415
{
416416
#ifdef CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN
417417
z_arch_switch_to_main_thread(_main_thread, _main_stack,
@@ -425,6 +425,7 @@ static void switch_to_main_thread(void)
425425
*/
426426
z_swap_unlocked();
427427
#endif
428+
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
428429
}
429430
#endif /* CONFIG_MULTITHREADING */
430431

@@ -519,9 +520,13 @@ FUNC_NORETURN void z_cstart(void)
519520
#else
520521
bg_thread_main(NULL, NULL, NULL);
521522

523+
/* LCOV_EXCL_START
524+
* We've already dumped coverage data at this point.
525+
*/
522526
irq_lock();
523527
while (true) {
524528
}
529+
/* LCOV_EXCL_STOP */
525530
#endif
526531

527532
/*
@@ -530,5 +535,5 @@ FUNC_NORETURN void z_cstart(void)
530535
* far.
531536
*/
532537

533-
CODE_UNREACHABLE;
538+
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
534539
}

0 commit comments

Comments
 (0)