From b38b2dd9fb7280fa2eb12bd623f4424f1b4b6f03 Mon Sep 17 00:00:00 2001 From: kar-rahul-aws Date: Thu, 16 May 2024 15:18:05 +0530 Subject: [PATCH 1/3] Add _Noreturn attribute in the template function to fix MISRA 17.11 advisory warnings --- examples/cmake_example/main.c | 6 ++++-- portable/template/portmacro.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/cmake_example/main.c b/examples/cmake_example/main.c index 00c5405b363..91875cda5a3 100644 --- a/examples/cmake_example/main.c +++ b/examples/cmake_example/main.c @@ -49,7 +49,7 @@ static void exampleTask( void * parameters ); /*-----------------------------------------------------------*/ -static void exampleTask( void * parameters ) +static _Noreturn void exampleTask( void * parameters ) { /* Unused parameters. */ ( void ) parameters; @@ -62,7 +62,7 @@ static void exampleTask( void * parameters ) } /*-----------------------------------------------------------*/ -void main( void ) +int main( void ) { static StaticTask_t exampleTaskTCB; static StackType_t exampleTaskStack[ configMINIMAL_STACK_SIZE ]; @@ -84,6 +84,8 @@ void main( void ) { /* Should not reach here. */ } + + return 0; } /*-----------------------------------------------------------*/ diff --git a/portable/template/portmacro.h b/portable/template/portmacro.h index 90668043cd0..6cb084e6f21 100644 --- a/portable/template/portmacro.h +++ b/portable/template/portmacro.h @@ -105,7 +105,7 @@ extern void vPortYield( void ); #define portYIELD() vPortYield() /* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) __attribute__( ( noreturn ) ) void vFunction( void * pvParameters ) #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) #if ( configNUMBER_OF_CORES > 1 ) From be1a0fa6d62aa5c9015aa89b7df67c31dff6688b Mon Sep 17 00:00:00 2001 From: kar-rahul-aws Date: Thu, 16 May 2024 15:19:45 +0530 Subject: [PATCH 2/3] Add _Noreturn attribute in function declaration --- examples/cmake_example/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/cmake_example/main.c b/examples/cmake_example/main.c index 91875cda5a3..05796c8a6c3 100644 --- a/examples/cmake_example/main.c +++ b/examples/cmake_example/main.c @@ -45,7 +45,7 @@ /*-----------------------------------------------------------*/ -static void exampleTask( void * parameters ); +static _Noreturn void exampleTask( void * parameters ); /*-----------------------------------------------------------*/ From 3df445fdb0baee524de6e31ac8f41eae142cf07f Mon Sep 17 00:00:00 2001 From: kar-rahul-aws Date: Thu, 16 May 2024 16:34:04 +0530 Subject: [PATCH 3/3] Code review suggestions --- examples/cmake_example/main.c | 4 ++-- portable/template/portmacro.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/cmake_example/main.c b/examples/cmake_example/main.c index 05796c8a6c3..b7ced4dd941 100644 --- a/examples/cmake_example/main.c +++ b/examples/cmake_example/main.c @@ -45,11 +45,11 @@ /*-----------------------------------------------------------*/ -static _Noreturn void exampleTask( void * parameters ); +static void exampleTask( void * parameters ) __attribute__( ( noreturn ) ); /*-----------------------------------------------------------*/ -static _Noreturn void exampleTask( void * parameters ) +static void exampleTask( void * parameters ) { /* Unused parameters. */ ( void ) parameters; diff --git a/portable/template/portmacro.h b/portable/template/portmacro.h index 6cb084e6f21..4a4a5876c62 100644 --- a/portable/template/portmacro.h +++ b/portable/template/portmacro.h @@ -105,7 +105,7 @@ extern void vPortYield( void ); #define portYIELD() vPortYield() /* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) __attribute__( ( noreturn ) ) void vFunction( void * pvParameters ) +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) __attribute__( ( noreturn ) ) #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) #if ( configNUMBER_OF_CORES > 1 )