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:15:19 +0300
committerGitHub <noreply@github.com>2023-12-07 13:15:19 +0300
commit877484cd7e6422e7bd7a4df4029afe8bca8b81e5 (patch)
tree229d20504780c1384da3c65b8708b1f8f2f416b2
parent15af8e072d7299d92a38a2f634c3bf3f095d3a32 (diff)
Fix MISRA C 2012 Rule 11.1 deviations (#856)
* Update callback function prototype to align with definition * Suppress unused function pointer parameter --------- Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> Co-authored-by: Ubuntu <ubuntu@ip-172-31-34-245.ap-northeast-1.compute.internal> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
-rw-r--r--MISRA.md10
-rw-r--r--event_groups.c8
-rw-r--r--include/event_groups.h4
-rw-r--r--stream_buffer.c9
4 files changed, 23 insertions, 8 deletions
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 )