diff --git a/MISRA.md b/MISRA.md index 9296cb961..1cca337ff 100644 --- a/MISRA.md +++ b/MISRA.md @@ -34,7 +34,6 @@ _Ref 8.4.2_ kernel unit tests. It is not meant to be directly accessed by the application and therefore, not declared in a header file. - #### Rule 8.6 MISRA C:2012 Rule 8.6: An identifier with external linkage shall have exactly @@ -45,6 +44,15 @@ _Ref 8.6.1_ definitions or no definition. FreeRTOS hook functions are implemented in the application and therefore, have no definition in the Kernel code. +#### Rule 11.1 +MISRA C:2012 Rule 11.1: Conversions shall not be performed between a pointer to +function and any other type. + +_Ref 11.1.1_ + - The pointer to function is casted into void to avoid unused parameter + compiler warning when Stream Buffer's Tx and Rx Completed callback feature is + not used. + #### Rule 11.3 MISRA C:2012 Rule 11.3: A cast shall not be performed between a pointer to diff --git a/event_groups.c b/event_groups.c index 68f8e9ddb..cb154a82c 100644 --- a/event_groups.c +++ b/event_groups.c @@ -506,7 +506,7 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, traceENTER_xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ); traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear ); - 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. */ + xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ); traceRETURN_xEventGroupClearBitsFromISR( xReturn ); @@ -735,7 +735,7 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) /* For internal use only - execute a 'set bits' command that was pended from * an interrupt. */ void vEventGroupSetBitsCallback( void * pvEventGroup, - const uint32_t ulBitsToSet ) + uint32_t ulBitsToSet ) { traceENTER_vEventGroupSetBitsCallback( pvEventGroup, ulBitsToSet ); @@ -751,7 +751,7 @@ void vEventGroupSetBitsCallback( void * pvEventGroup, /* For internal use only - execute a 'clear bits' command that was pended from * an interrupt. */ void vEventGroupClearBitsCallback( void * pvEventGroup, - const uint32_t ulBitsToClear ) + uint32_t ulBitsToClear ) { traceENTER_vEventGroupClearBitsCallback( pvEventGroup, ulBitsToClear ); @@ -812,7 +812,7 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, traceENTER_xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ); traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet ); - 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. */ + xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ); traceRETURN_xEventGroupSetBitsFromISR( xReturn ); diff --git a/include/event_groups.h b/include/event_groups.h index f1f86fb7f..d66ab262c 100644 --- a/include/event_groups.h +++ b/include/event_groups.h @@ -807,9 +807,9 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION; /* For internal use only. */ void vEventGroupSetBitsCallback( void * pvEventGroup, - const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION; + uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION; void vEventGroupClearBitsCallback( void * pvEventGroup, - const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; + uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; #if ( configUSE_TRACE_FACILITY == 1 ) diff --git a/stream_buffer.c b/stream_buffer.c index 35e67cf35..9899e30ee 100644 --- a/stream_buffer.c +++ b/stream_buffer.c @@ -1507,10 +1507,17 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer, } #else { + /* MISRA Ref 11.1.1 [Object type casting] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-111 */ + /* coverity[misra_c_2012_rule_11_1_violation] */ ( void ) pxSendCompletedCallback; + + /* MISRA Ref 11.1.1 [Object type casting] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-111 */ + /* coverity[misra_c_2012_rule_11_1_violation] */ ( void ) pxReceiveCompletedCallback; } - #endif + #endif /* if ( configUSE_SB_COMPLETED_CALLBACK == 1 ) */ } #if ( configUSE_TRACE_FACILITY == 1 )