Skip to content

Commit 877484c

Browse files
chinglee-iotUbuntuactions-userkar-rahul-awsaggarg
authored
Fix MISRA C 2012 Rule 11.1 deviations (FreeRTOS#856)
* Update callback function prototype to align with definition * Suppress unused function pointer parameter --------- Signed-off-by: Gaurav Aggarwal <[email protected]> Co-authored-by: Ubuntu <[email protected]> Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Rahul Kar <[email protected]> Co-authored-by: Gaurav-Aggarwal-AWS <[email protected]> Co-authored-by: Gaurav Aggarwal <[email protected]>
1 parent 15af8e0 commit 877484c

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

MISRA.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ _Ref 8.4.2_
3434
kernel unit tests. It is not meant to be directly accessed by the application
3535
and therefore, not declared in a header file.
3636

37-
3837
#### Rule 8.6
3938

4039
MISRA C:2012 Rule 8.6: An identifier with external linkage shall have exactly
@@ -45,6 +44,15 @@ _Ref 8.6.1_
4544
definitions or no definition. FreeRTOS hook functions are implemented in
4645
the application and therefore, have no definition in the Kernel code.
4746

47+
#### Rule 11.1
48+
MISRA C:2012 Rule 11.1: Conversions shall not be performed between a pointer to
49+
function and any other type.
50+
51+
_Ref 11.1.1_
52+
- The pointer to function is casted into void to avoid unused parameter
53+
compiler warning when Stream Buffer's Tx and Rx Completed callback feature is
54+
not used.
55+
4856
#### Rule 11.3
4957

5058
MISRA C:2012 Rule 11.3: A cast shall not be performed between a pointer to

event_groups.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup,
506506
traceENTER_xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear );
507507

508508
traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear );
509-
xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ); /*lint !e9087 Can't avoid cast to void* as a generic callback function not specific to this use case. Callback casts back to original type so safe. */
509+
xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL );
510510

511511
traceRETURN_xEventGroupClearBitsFromISR( xReturn );
512512

@@ -735,7 +735,7 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup )
735735
/* For internal use only - execute a 'set bits' command that was pended from
736736
* an interrupt. */
737737
void vEventGroupSetBitsCallback( void * pvEventGroup,
738-
const uint32_t ulBitsToSet )
738+
uint32_t ulBitsToSet )
739739
{
740740
traceENTER_vEventGroupSetBitsCallback( pvEventGroup, ulBitsToSet );
741741

@@ -751,7 +751,7 @@ void vEventGroupSetBitsCallback( void * pvEventGroup,
751751
/* For internal use only - execute a 'clear bits' command that was pended from
752752
* an interrupt. */
753753
void vEventGroupClearBitsCallback( void * pvEventGroup,
754-
const uint32_t ulBitsToClear )
754+
uint32_t ulBitsToClear )
755755
{
756756
traceENTER_vEventGroupClearBitsCallback( pvEventGroup, ulBitsToClear );
757757

@@ -812,7 +812,7 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits,
812812
traceENTER_xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken );
813813

814814
traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet );
815-
xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ); /*lint !e9087 Can't avoid cast to void* as a generic callback function not specific to this use case. Callback casts back to original type so safe. */
815+
xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken );
816816

817817
traceRETURN_xEventGroupSetBitsFromISR( xReturn );
818818

include/event_groups.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,9 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
807807

808808
/* For internal use only. */
809809
void vEventGroupSetBitsCallback( void * pvEventGroup,
810-
const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;
810+
uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;
811811
void vEventGroupClearBitsCallback( void * pvEventGroup,
812-
const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
812+
uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
813813

814814

815815
#if ( configUSE_TRACE_FACILITY == 1 )

stream_buffer.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1507,10 +1507,17 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
15071507
}
15081508
#else
15091509
{
1510+
/* MISRA Ref 11.1.1 [Object type casting] */
1511+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-111 */
1512+
/* coverity[misra_c_2012_rule_11_1_violation] */
15101513
( void ) pxSendCompletedCallback;
1514+
1515+
/* MISRA Ref 11.1.1 [Object type casting] */
1516+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-111 */
1517+
/* coverity[misra_c_2012_rule_11_1_violation] */
15111518
( void ) pxReceiveCompletedCallback;
15121519
}
1513-
#endif
1520+
#endif /* if ( configUSE_SB_COMPLETED_CALLBACK == 1 ) */
15141521
}
15151522

15161523
#if ( configUSE_TRACE_FACILITY == 1 )

0 commit comments

Comments
 (0)