From ab6ccbb04e7bbd9767a9e57b3c60c7fa3d64d52c Mon Sep 17 00:00:00 2001 From: Hesham Almatary Date: Wed, 18 Feb 2026 07:35:40 +0000 Subject: [PATCH] RISC-V: fix xTaskReturnAddress type xTaskReturnAddress holds a [function] pointer, never an integer address. Use a proper exclusive function pointer type for this variable. Furthermore, use NULL instead of 0 for an invalid function pointer value This typedef could be made more generic for FreeRTOS-Kernel and not just for RISC-V; vApplicationTaskExit used to be declared/defined in previous versions and ideally could just be brought back. Signed-off-by: Hesham Almatary --- portable/GCC/RISC-V/port.c | 4 ++-- portable/GCC/RISC-V/portmacro.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/portable/GCC/RISC-V/port.c b/portable/GCC/RISC-V/port.c index 8fe7a25d5..44f6ab384 100644 --- a/portable/GCC/RISC-V/port.c +++ b/portable/GCC/RISC-V/port.c @@ -54,7 +54,7 @@ #ifdef configTASK_RETURN_ADDRESS #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS #else - #define portTASK_RETURN_ADDRESS 0 + #define portTASK_RETURN_ADDRESS NULL #endif /* The stack used by interrupt service routines. Set configISR_STACK_SIZE_WORDS @@ -99,7 +99,7 @@ size_t xCriticalNesting = ( size_t ) 0xaaaaaaaa; size_t * pxCriticalNesting = &xCriticalNesting; /* Used to catch tasks that attempt to return from their implementing function. */ -size_t xTaskReturnAddress = ( size_t ) portTASK_RETURN_ADDRESS; +ReturnFunctionType_t xTaskReturnAddress = ( ReturnFunctionType_t ) portTASK_RETURN_ADDRESS; /* Set configCHECK_FOR_STACK_OVERFLOW to 3 to add ISR stack checking to task * stack checking. A problem in the ISR stack will trigger an assert, not call diff --git a/portable/GCC/RISC-V/portmacro.h b/portable/GCC/RISC-V/portmacro.h index f7d2f3ef1..eaa7a99a9 100644 --- a/portable/GCC/RISC-V/portmacro.h +++ b/portable/GCC/RISC-V/portmacro.h @@ -66,6 +66,7 @@ typedef portSTACK_TYPE StackType_t; typedef portBASE_TYPE BaseType_t; typedef portUBASE_TYPE UBaseType_t; typedef portUBASE_TYPE TickType_t; +typedef void (*ReturnFunctionType_t)( void ); /* Legacy type definitions. */ #define portCHAR char