From 0801c91bc6c7a6cfd6e248a07d952619fc144653 Mon Sep 17 00:00:00 2001 From: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Date: Thu, 16 May 2024 21:11:05 +0530 Subject: [PATCH] Add Noreturn attribute in template port for static analysis (#1060) * Add _Noreturn attribute in the template function to fix MISRA 17.11 advisory warnings * Add _Noreturn attribute in function declaration * Code review suggestions --- 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 00c5405b3..b7ced4dd9 100644 --- a/examples/cmake_example/main.c +++ b/examples/cmake_example/main.c @@ -45,7 +45,7 @@ /*-----------------------------------------------------------*/ -static void exampleTask( void * parameters ); +static void exampleTask( void * parameters ) __attribute__( ( noreturn ) ); /*-----------------------------------------------------------*/ @@ -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 90668043c..4a4a5876c 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 ) void vFunction( void * pvParameters ) __attribute__( ( noreturn ) ) #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) #if ( configNUMBER_OF_CORES > 1 )