Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FreeRTOS/FreeRTOS-Kernel.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchinglee-iot <61685396+chinglee-iot@users.noreply.github.com>2023-12-07 13:51:14 +0300
committerGitHub <noreply@github.com>2023-12-07 13:51:14 +0300
commitd95b05ea5f5697f1435d303fe1ea27321d3147f4 (patch)
tree95ddd71491d5ecb7ff313183893ffef659afbce0
parent877484cd7e6422e7bd7a4df4029afe8bca8b81e5 (diff)
Suppress MISRA C:2012 rule 21.6 for snprintf (#877)
Suppress MISRA C:2012 rule 21.6 for snprintf
-rw-r--r--MISRA.md9
-rw-r--r--tasks.c28
2 files changed, 32 insertions, 5 deletions
diff --git a/MISRA.md b/MISRA.md
index 1cca337ff..734a51291 100644
--- a/MISRA.md
+++ b/MISRA.md
@@ -107,6 +107,15 @@ _Ref 11.5.5_
because data storage buffers are implemented as uint8_t arrays for the
ease of sizing, alignment and access.
+#### Rule 21.6
+
+MISRA C-2012 Rule 21.6: The Standard Library input/output functions shall not
+be used.
+
+_Ref 21.6.1_
+ - 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 7c05bd531..1bb8a05a9 100644
--- a/tasks.c
+++ b/tasks.c
@@ -7348,6 +7348,9 @@ static void prvResetNextTaskUnblockTime( void )
{
/* Write the rest of the string. */
#if ( ( 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 */
+ /* coverity[misra_c_2012_rule_21_6_violation] */
iSnprintfReturnValue = snprintf( pcWriteBuffer,
uxBufferLength - uxConsumedBufferLength,
"\t%c\t%u\t%u\t%u\t0x%x\r\n",
@@ -7355,15 +7358,18 @@ 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 */
+ /* coverity[misra_c_2012_rule_21_6_violation] */
iSnprintfReturnValue = snprintf( pcWriteBuffer,
uxBufferLength - uxConsumedBufferLength,
"\t%c\t%u\t%u\t%u\r\n",
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 );
@@ -7496,21 +7502,27 @@ static void prvResetNextTaskUnblockTime( void )
{
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED
{
+ /* MISRA Ref 21.6.1 [snprintf for utility] */
+ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-216 */
+ /* coverity[misra_c_2012_rule_21_6_violation] */
iSnprintfReturnValue = snprintf( pcWriteBuffer,
uxBufferLength - uxConsumedBufferLength,
"\t%lu\t\t%lu%%\r\n",
pxTaskStatusArray[ x ].ulRunTimeCounter,
ulStatsAsPercentage );
}
- #else
+ #else /* ifdef portLU_PRINTF_SPECIFIER_REQUIRED */
{
/* sizeof( int ) == sizeof( long ) so a smaller
* printf() library can be used. */
+ /* MISRA Ref 21.6.1 [snprintf for utility] */
+ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-216 */
+ /* coverity[misra_c_2012_rule_21_6_violation] */
iSnprintfReturnValue = snprintf( pcWriteBuffer,
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 */
}
@@ -7520,6 +7532,9 @@ static void prvResetNextTaskUnblockTime( void )
* consumed less than 1% of the total run time. */
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED
{
+ /* MISRA Ref 21.6.1 [snprintf for utility] */
+ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-216 */
+ /* coverity[misra_c_2012_rule_21_6_violation] */
iSnprintfReturnValue = snprintf( pcWriteBuffer,
uxBufferLength - uxConsumedBufferLength,
"\t%lu\t\t<1%%\r\n",
@@ -7529,10 +7544,13 @@ static void prvResetNextTaskUnblockTime( void )
{
/* sizeof( int ) == sizeof( long ) so a smaller
* printf() library can be used. */
+ /* MISRA Ref 21.6.1 [snprintf for utility] */
+ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-216 */
+ /* coverity[misra_c_2012_rule_21_6_violation] */
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 */
}