From b4ed4d0dcaa9777c33cec2ada1720b980ff9e357 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Tue, 18 Jun 2024 11:28:33 +0530 Subject: [PATCH] Fix MISRA violations --- source/FreeRTOS_DNS_Parser.c | 2 ++ source/FreeRTOS_RA.c | 2 +- source/FreeRTOS_Sockets.c | 3 ++- source/FreeRTOS_TCP_IP.c | 4 ++++ source/FreeRTOS_TCP_State_Handling_IPv4.c | 2 +- source/FreeRTOS_TCP_State_Handling_IPv6.c | 2 +- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c index 0b328d16d..13fb75a85 100644 --- a/source/FreeRTOS_DNS_Parser.c +++ b/source/FreeRTOS_DNS_Parser.c @@ -330,6 +330,7 @@ #if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 ) uxResult = DNS_ReadNameField( &xSet, sizeof( xSet.pcName ) ); + ( void ) uxResult; #endif } } @@ -359,6 +360,7 @@ { uxResult = DNS_ReadNameField( &xSet, sizeof( xSet.pcName ) ); + ( void ) uxResult; } else #endif /* ipconfigUSE_DNS_CACHE || ipconfigDNS_USE_CALLBACKS */ diff --git a/source/FreeRTOS_RA.c b/source/FreeRTOS_RA.c index d0e6991e6..446dfae98 100644 --- a/source/FreeRTOS_RA.c +++ b/source/FreeRTOS_RA.c @@ -489,7 +489,7 @@ if( pxEndPoint->xRAData.bits.bRouterReplied != pdFALSE_UNSIGNED ) { /* Obtained configuration from a router. */ - uxNewReloadTime = pdMS_TO_TICKS( 1000U * pxEndPoint->xRAData.ulPreferredLifeTime ); + uxNewReloadTime = pdMS_TO_TICKS( ( 1000U * ( uint64_t ) pxEndPoint->xRAData.ulPreferredLifeTime ) ); pxEndPoint->xRAData.eRAState = eRAStatePreLease; iptraceRA_SUCCEEDED( &( pxEndPoint->ipv6_settings.xIPAddress ) ); FreeRTOS_printf( ( "RA: succeeded, using IP address %pip Reload after %u seconds\n", diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index d143d1646..83d0cb045 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -2893,6 +2893,8 @@ BaseType_t FreeRTOS_setsockopt( Socket_t xSocket, /* The type cast of the pointer expression "A" to * type "B" removes const qualifier from the pointed to type. */ + ipconfigISO_STRICTNESS_VIOLATION_START; + /* MISRA Ref 11.8.1 [Function pointer and use of const pointer] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-118 */ @@ -2901,7 +2903,6 @@ BaseType_t FreeRTOS_setsockopt( Socket_t xSocket, /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-111 */ /* coverity[misra_c_2012_rule_11_8_violation] */ /* coverity[misra_c_2012_rule_11_1_violation] */ - ipconfigISO_STRICTNESS_VIOLATION_START; pxSocket->pxUserWakeCallback = ( SocketWakeupCallback_t ) pvOptionValue; ipconfigISO_STRICTNESS_VIOLATION_END; xReturn = 0; diff --git a/source/FreeRTOS_TCP_IP.c b/source/FreeRTOS_TCP_IP.c index 528224b40..dafbf3c0a 100644 --- a/source/FreeRTOS_TCP_IP.c +++ b/source/FreeRTOS_TCP_IP.c @@ -277,6 +277,10 @@ static BaseType_t vTCPRemoveTCPChild( const FreeRTOS_Socket_t * pxChildSocket ) { BaseType_t xReturn = pdFALSE; + + /* MISRA Ref 11.3.1 [Misaligned access] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ + /* coverity[misra_c_2012_rule_11_3_violation] */ const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) ); /* MISRA Ref 11.3.1 [Misaligned access] */ diff --git a/source/FreeRTOS_TCP_State_Handling_IPv4.c b/source/FreeRTOS_TCP_State_Handling_IPv4.c index 4badde138..d7da55d49 100644 --- a/source/FreeRTOS_TCP_State_Handling_IPv4.c +++ b/source/FreeRTOS_TCP_State_Handling_IPv4.c @@ -200,7 +200,7 @@ FreeRTOS_Socket_t * prvHandleListen_IPV4( FreeRTOS_Socket_t * pxSocket, /* Close the socket if it was newly created. */ if( xIsNewSocket == pdTRUE ) { - vSocketClose( pxReturn ); + ( void ) vSocketClose( pxReturn ); } pxReturn = NULL; diff --git a/source/FreeRTOS_TCP_State_Handling_IPv6.c b/source/FreeRTOS_TCP_State_Handling_IPv6.c index ab9020995..d13211a02 100644 --- a/source/FreeRTOS_TCP_State_Handling_IPv6.c +++ b/source/FreeRTOS_TCP_State_Handling_IPv6.c @@ -200,7 +200,7 @@ FreeRTOS_Socket_t * prvHandleListen_IPV6( FreeRTOS_Socket_t * pxSocket, /* Close the socket if it was newly created. */ if( xIsNewSocket == pdTRUE ) { - vSocketClose( pxReturn ); + ( void ) vSocketClose( pxReturn ); } pxReturn = NULL;