From 3470d6545c974edfd9d4a31319e6f113f4683dec Mon Sep 17 00:00:00 2001 From: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Sat, 17 Feb 2024 01:20:35 +0000 Subject: [PATCH] Fix small bugs --- include/FreeRTOS.h | 8 ++++---- portable/ThirdParty/GCC/Posix/portmacro.h | 2 +- tasks.c | 7 +++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index 0c386cc4d..b993893e7 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -96,6 +96,10 @@ #define configNUMBER_OF_CORES 1 #endif +#ifndef configUSE_MALLOC_FAILED_HOOK + #define configUSE_MALLOC_FAILED_HOOK 0 +#endif + /* Basic FreeRTOS definitions. */ #include "projdefs.h" @@ -2649,10 +2653,6 @@ #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() #endif -#ifndef configUSE_MALLOC_FAILED_HOOK - #define configUSE_MALLOC_FAILED_HOOK 0 -#endif - #ifndef portPRIVILEGE_BIT #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 ) #endif diff --git a/portable/ThirdParty/GCC/Posix/portmacro.h b/portable/ThirdParty/GCC/Posix/portmacro.h index 6de25da45..d1e35d125 100644 --- a/portable/ThirdParty/GCC/Posix/portmacro.h +++ b/portable/ThirdParty/GCC/Posix/portmacro.h @@ -64,7 +64,7 @@ typedef long BaseType_t; typedef unsigned long UBaseType_t; typedef unsigned long TickType_t; -#define portMAX_DELAY ( TickType_t ) ULONG_MAX +#define portMAX_DELAY ( ( TickType_t ) ULONG_MAX ) #define portTICK_TYPE_IS_ATOMIC 1 diff --git a/tasks.c b/tasks.c index 6c399dbf5..085e4866f 100644 --- a/tasks.c +++ b/tasks.c @@ -3506,6 +3506,9 @@ static BaseType_t prvCreateIdleTasks( void ) TaskFunction_t pxIdleTaskFunction = NULL; BaseType_t xIdleTaskNameIndex; + /* Make sure that the below for loop doesn't go over the configIDLE_TASK_NAME macro. */ + configASSERT( sizeof( configIDLE_TASK_NAME ) >= configMAX_TASK_NAME_LEN ); + for( xIdleTaskNameIndex = ( BaseType_t ) 0; xIdleTaskNameIndex < ( BaseType_t ) configMAX_TASK_NAME_LEN; xIdleTaskNameIndex++ ) { cIdleName[ xIdleTaskNameIndex ] = configIDLE_TASK_NAME[ xIdleTaskNameIndex ]; @@ -3517,6 +3520,10 @@ static BaseType_t prvCreateIdleTasks( void ) { break; } + else if( xIdleTaskNameIndex >= sizeof( configIDLE_TASK_NAME ) ) + { + break; + } else { mtCOVERAGE_TEST_MARKER();