From 7d2220724c43605d98fd2d144886177db946a92e Mon Sep 17 00:00:00 2001 From: Gaurav Aggarwal Date: Thu, 7 Dec 2023 10:12:33 +0000 Subject: [PATCH] Code review suggestions Signed-off-by: Gaurav Aggarwal --- MISRA.md | 11 ++++------- tasks.c | 8 ++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/MISRA.md b/MISRA.md index 9265abd0cd8..81fce6451e1 100644 --- a/MISRA.md +++ b/MISRA.md @@ -101,15 +101,12 @@ _Ref 11.5.5_ #### Rule 21.6 MISRA C-2012 Rule 21.6: The Standard Library input/output functions shall not - be used. +be used. _Ref 21.6.1_ -- This rule warns about the use of standard library input/output functions - as they might have implementation defined or undefined behavior. The function - 'snprintf' is used for debugging only ( when configUSE_TRACE_FACILITY is - set to 1 and configUSE_STATS_FORMATTING_FUNCTIONS is set to greater than 0 ) - and is not part of the 'core' kernel code. - + - The Standard Library function snprintf is used in vTaskListTasks and + vTaskGetRunTimeStatistics APIs, both of which are utility functions only and + are not considered part of core kernel implementation. ### MISRA configuration diff --git a/tasks.c b/tasks.c index a1f15bd9efc..1bb8a05a981 100644 --- a/tasks.c +++ b/tasks.c @@ -7358,7 +7358,7 @@ static void prvResetNextTaskUnblockTime( void ) ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber, - ( unsigned int ) pxTaskStatusArray[ x ].uxCoreAffinityMask ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */ + ( unsigned int ) pxTaskStatusArray[ x ].uxCoreAffinityMask ); #else /* ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */ /* MISRA Ref 21.6.1 [snprintf for utility] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-216 */ @@ -7369,7 +7369,7 @@ static void prvResetNextTaskUnblockTime( void ) cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, - ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */ + ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber ); #endif /* ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */ uxCharsWrittenBySnprintf = prvSnprintfReturnValueToCharsWritten( iSnprintfReturnValue, uxBufferLength - uxConsumedBufferLength ); @@ -7522,7 +7522,7 @@ static void prvResetNextTaskUnblockTime( void ) uxBufferLength - uxConsumedBufferLength, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, - ( unsigned int ) ulStatsAsPercentage ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */ + ( unsigned int ) ulStatsAsPercentage ); } #endif /* ifdef portLU_PRINTF_SPECIFIER_REQUIRED */ } @@ -7550,7 +7550,7 @@ static void prvResetNextTaskUnblockTime( void ) iSnprintfReturnValue = snprintf( pcWriteBuffer, uxBufferLength - uxConsumedBufferLength, "\t%u\t\t<1%%\r\n", - ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */ + ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter ); } #endif /* ifdef portLU_PRINTF_SPECIFIER_REQUIRED */ }