Skip to content

Commit

Permalink
Code review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Aggarwal <[email protected]>
  • Loading branch information
aggarg committed Dec 7, 2023
1 parent 7eb108a commit 7d22207
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
11 changes: 4 additions & 7 deletions MISRA.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 );

Expand Down Expand Up @@ -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 */
}
Expand Down Expand Up @@ -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 */
}
Expand Down

0 comments on commit 7d22207

Please sign in to comment.