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

@ -9,11 +9,12 @@
#include <zephyr/dfu/mcuboot.h>
/* Main entry point */
void main(void)
int main(void)
{
printk("Launching primary slot application on %s\n", CONFIG_BOARD);
/* Perform a permanent swap of MCUBoot application */
boot_request_upgrade(1);
printk("Secondary application ready for swap, rebooting\n");
sys_reboot(SYS_REBOOT_COLD);
return 0;
}

View file

@ -7,7 +7,8 @@
#include <zephyr/kernel.h>
/* Main entry point */
void main(void)
int main(void)
{
printk("Swapped application booted on %s\n", CONFIG_BOARD);
return 0;
}

View file

@ -7,7 +7,8 @@
#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
void main(void)
int main(void)
{
printk("Hello World! %s\n", CONFIG_BOARD);
return 0;
}