From e6af9f22e568c93416e509b6c4d12cb8e82c13c4 Mon Sep 17 00:00:00 2001 From: Abhinav <83628416+abhinavuser@users.noreply.github.com> Date: Fri, 24 Apr 2026 05:22:43 +0530 Subject: [PATCH] fix: add missing xSemaphoreGive and fix formatting in console.c (#1400) In FreeRTOS_Plus_TCP_Echo_Posix/console.c: - Add missing xSemaphoreGive() call in console_print() to prevent mutex starvation after vprintf completes - Fix uncrustify formatting: indent preprocessor directives (#if/#else/#endif), add space between #if and condition, remove space in empty xSemaphoreCreateMutex() --- .../Demo/FreeRTOS_Plus_TCP_Echo_Posix/console.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/console.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/console.c index ec6a047baef..d9bff9485e6 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/console.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/console.c @@ -34,12 +34,22 @@ #include #include -SemaphoreHandle_t xStdioMutex; -StaticSemaphore_t xStdioMutexBuffer; +#include "console.h" + +static SemaphoreHandle_t xStdioMutex; +static StaticSemaphore_t xStdioMutexBuffer; void console_init( void ) { - xStdioMutex = xSemaphoreCreateMutexStatic( &xStdioMutexBuffer ); + #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + xStdioMutex = xSemaphoreCreateMutexStatic( &xStdioMutexBuffer ); + } + #else /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */ + { + xStdioMutex = xSemaphoreCreateMutex(); + } + #endif /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */ } void console_print( const char * fmt, @@ -53,6 +63,7 @@ void console_print( const char * fmt, vprintf( fmt, vargs ); + xSemaphoreGive( xStdioMutex ); va_end( vargs ); }