samples, tests, boards: Switch main return type from void to int

As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.

Most of these changes were automated using coccinelle with the following
script:

@@
@@
- void
+ int
main(...) {
	...
-	return;
+	return 0;
	...
}

Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2023-02-07 21:00:59 -08:00 committed by Stephanos Ioannidis
commit 0b90fd5adf
447 changed files with 1617 additions and 1231 deletions

View file

@ -332,11 +332,7 @@ static void bg_thread_main(void *unused1, void *unused2, void *unused3)
z_mem_manage_boot_finish();
#endif /* CONFIG_MMU */
#ifdef CONFIG_CPP_MAIN
extern int main(void);
#else
extern void main(void);
#endif
(void)main();