From 99587fc2c20d662cc4c72c94bb83233accd0e87f Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Tue, 21 Nov 2023 07:35:10 +0000 Subject: [PATCH 01/19] Update coverity --- source/include/FreeRTOSIPConfigDefaults.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index 97a0b08684..8e06a28171 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -3064,7 +3064,7 @@ #ifndef FreeRTOS_debug_printf #ifdef configPRINTF - #define FreeRTOS_debug_printf( MSG ) if( ipconfigHAS_DEBUG_PRINTF ) configPRINTF( MSG ) + #define FreeRTOS_debug_printf( MSG ) if( ipconfigHAS_DEBUG_PRINTF ) { configPRINTF( MSG ) } #else #define FreeRTOS_debug_printf( MSG ) do {} while( ipFALSE_BOOL ) #endif @@ -3100,7 +3100,7 @@ #ifndef FreeRTOS_printf #ifdef configPRINTF - #define FreeRTOS_printf( MSG ) if( ipconfigHAS_PRINTF ) configPRINTF( MSG ) + #define FreeRTOS_printf( MSG ) if( ipconfigHAS_PRINTF ) { configPRINTF( MSG ) } #else #define FreeRTOS_printf( MSG ) do {} while( ipFALSE_BOOL ) #endif From 0ae9aebfce80b434f552edd4357ac4df23c5038f Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Thu, 23 Nov 2023 11:17:02 +0000 Subject: [PATCH 02/19] Misra fix 11.3 --- source/FreeRTOS_DNS.c | 4 +--- source/FreeRTOS_RA.c | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/FreeRTOS_DNS.c b/source/FreeRTOS_DNS.c index 9fb62a1969..7dbacd56a2 100644 --- a/source/FreeRTOS_DNS.c +++ b/source/FreeRTOS_DNS.c @@ -1081,9 +1081,7 @@ /* 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 DNSMessage_t * pxDNSMessageHeader = - ( ( const DNSMessage_t * ) - pxReceiveBuffer->pucPayloadBuffer ); + const DNSMessage_t * pxDNSMessageHeader = ( ( const DNSMessage_t * ) pxReceiveBuffer->pucPayloadBuffer ); #if ( ipconfigUSE_MDNS == 1 ) /* _HT_ changed 'pxReceiveBuffer->sin_port' to 'usPort' */ diff --git a/source/FreeRTOS_RA.c b/source/FreeRTOS_RA.c index 0a5c10ee4a..9f9ef8fc2c 100644 --- a/source/FreeRTOS_RA.c +++ b/source/FreeRTOS_RA.c @@ -168,6 +168,10 @@ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ /* coverity[misra_c_2012_rule_11_3_violation] */ pxICMPPacket = ( ( ICMPPacket_IPv6_t * ) pxDescriptor->pucEthernetBuffer ); + + /* 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] */ xRASolicitationRequest = ( ( ICMPRouterSolicitation_IPv6_t * ) &( pxICMPPacket->xICMPHeaderIPv6 ) ); pxDescriptor->xDataLength = uxNeededSize; From aae4c304ca0ba409c2adf339e4122547bfbca487 Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Thu, 23 Nov 2023 16:51:15 +0000 Subject: [PATCH 03/19] MISRA fix 12.1 --- source/portable/BufferManagement/BufferAllocation_2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index 95ae9fb695..afc15028e5 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -77,7 +77,7 @@ #define ASSERT_CONCAT_( a, b ) a ## b #define ASSERT_CONCAT( a, b ) ASSERT_CONCAT_( a, b ) #define STATIC_ASSERT( e ) \ - enum { ASSERT_CONCAT( assert_line_, __LINE__ ) = 1 / ( !!( e ) ) } + enum { ASSERT_CONCAT( assert_line_, __LINE__ ) = ( 1 / ( !!( e ) ) ) } STATIC_ASSERT( ipconfigETHERNET_MINIMUM_PACKET_BYTES <= baMINIMAL_BUFFER_SIZE ); #endif From b323a54326b5cf59278325e8f2c22fc7b07a7fc0 Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Thu, 23 Nov 2023 17:05:35 +0000 Subject: [PATCH 04/19] MISRA fix 20.10 --- source/portable/BufferManagement/BufferAllocation_2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index afc15028e5..02904bf155 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -70,10 +70,10 @@ /* Compile time assertion with zero runtime effects * it will assert on 'e' not being zero, as it tries to divide by it, * will also print the line where the error occurred in case of failure */ -/* MISRA Ref 20.10.1 [Lack of sizeof operator and compile time error checking] */ -/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2010 */ -/* coverity[misra_c_2012_rule_20_10_violation] */ #if defined( ipconfigETHERNET_MINIMUM_PACKET_BYTES ) + /* MISRA Ref 20.10.1 [Lack of sizeof operator and compile time error checking] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2010 */ + /* coverity[misra_c_2012_rule_20_10_violation] */ #define ASSERT_CONCAT_( a, b ) a ## b #define ASSERT_CONCAT( a, b ) ASSERT_CONCAT_( a, b ) #define STATIC_ASSERT( e ) \ From db87b43375912b95d3167990ddae64965813e57c Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Thu, 23 Nov 2023 17:07:19 +0000 Subject: [PATCH 05/19] MISRA fix 20.5 --- source/include/FreeRTOS_IPv6_Private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/include/FreeRTOS_IPv6_Private.h b/source/include/FreeRTOS_IPv6_Private.h index 1e5ad5d07b..e00ab19562 100644 --- a/source/include/FreeRTOS_IPv6_Private.h +++ b/source/include/FreeRTOS_IPv6_Private.h @@ -57,10 +57,10 @@ /* The offset into an IP packet into which the IP data (payload) starts. */ #define ipIPv6_PAYLOAD_OFFSET ( sizeof( IPPacket_IPv6_t ) ) +/* The maximum UDP payload length. */ /* MISRA Ref 20.5.1 [Use of undef] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2051 */ /* coverity[misra_c_2012_rule_20_5_violation] */ -/* The maximum UDP payload length. */ #undef ipMAX_UDP_PAYLOAD_LENGTH #define ipMAX_UDP_PAYLOAD_LENGTH ( ( ipconfigNETWORK_MTU - ipSIZE_OF_IPv6_HEADER ) - ipSIZE_OF_UDP_HEADER ) /* The offset into a UDP packet at which the UDP data (payload) starts. */ From c31b4b91a726f6a4b6e279a4153e41c8d40b5ddb Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Fri, 24 Nov 2023 04:06:07 +0000 Subject: [PATCH 06/19] MISRA fix 8.5 --- source/include/FreeRTOS_IPv6_Sockets.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/source/include/FreeRTOS_IPv6_Sockets.h b/source/include/FreeRTOS_IPv6_Sockets.h index e435affc6e..c9a931e67a 100644 --- a/source/include/FreeRTOS_IPv6_Sockets.h +++ b/source/include/FreeRTOS_IPv6_Sockets.h @@ -90,13 +90,6 @@ */ void prv_ntop6_search_zeros( struct sNTOP6_Set * pxSet ); -/* - * Convert a string like 'fe80::8d11:cd9b:8b66:4a80' - * to a 16-byte IPv6 address - */ - const char * FreeRTOS_inet_ntop6( const void * pvSource, - char * pcDestination, - socklen_t uxSize ); /** @brief Called by pxTCPSocketLookup(), this function will check if a socket * is connected to a remote IP-address. It will be called from a loop From e564987859f657da6a2ed3034812de4f2eb99a6b Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Fri, 24 Nov 2023 04:15:14 +0000 Subject: [PATCH 07/19] MISRA fix 8.8 --- source/FreeRTOS_DHCP.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/FreeRTOS_DHCP.c b/source/FreeRTOS_DHCP.c index 19a50bafd0..3532d31c55 100644 --- a/source/FreeRTOS_DHCP.c +++ b/source/FreeRTOS_DHCP.c @@ -843,7 +843,7 @@ * using it. * @param[in] pxEndPoint The end-point that stops using the socket. */ - void prvCloseDHCPSocket( NetworkEndPoint_t * pxEndPoint ) + static void prvCloseDHCPSocket( NetworkEndPoint_t * pxEndPoint ) { if( ( EP_DHCPData.xDHCPSocket == NULL ) || ( EP_DHCPData.xDHCPSocket != xDHCPv4Socket ) ) { From 463489045bdd6376f4a59a2b49b8c4e29768dec2 Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Fri, 24 Nov 2023 07:22:14 +0000 Subject: [PATCH 08/19] MISRA fix 9.1 --- source/FreeRTOS_TCP_IP_IPv6.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/FreeRTOS_TCP_IP_IPv6.c b/source/FreeRTOS_TCP_IP_IPv6.c index ce1ac13049..d5a537d41b 100644 --- a/source/FreeRTOS_TCP_IP_IPv6.c +++ b/source/FreeRTOS_TCP_IP_IPv6.c @@ -134,6 +134,7 @@ BaseType_t xProcessReceivedTCPPacket_IPV6( NetworkBufferDescriptor_t * pxDescrip /* coverity[misra_c_2012_rule_11_3_violation] */ const IPHeader_IPv6_t * pxIPHeader_IPv6 = ( ( IPHeader_IPv6_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] ) ); ( void ) memcpy( xRemoteIP.xIPAddress.xIP_IPv6.ucBytes, pxIPHeader_IPv6->xSourceAddress.ucBytes, sizeof( IPv6_Address_t ) ); + xRemoteIP.xIs_IPv6 = pdTRUE; /* Find the destination socket, and if not found: return a socket listing to * the destination PORT. */ From 5ebedb51eb1d4f903d8422705196cbe4767d6398 Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Fri, 24 Nov 2023 07:48:07 +0000 Subject: [PATCH 09/19] MISRA fix 17.7 --- source/FreeRTOS_DHCP.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/FreeRTOS_DHCP.c b/source/FreeRTOS_DHCP.c index 3532d31c55..1effc8f2a0 100644 --- a/source/FreeRTOS_DHCP.c +++ b/source/FreeRTOS_DHCP.c @@ -905,7 +905,7 @@ ( void ) FreeRTOS_setsockopt( xDHCPv4Socket, 0, FREERTOS_SO_RCVTIMEO, &( xTimeoutTime ), sizeof( TickType_t ) ); ( void ) FreeRTOS_setsockopt( xDHCPv4Socket, 0, FREERTOS_SO_SNDTIMEO, &( xTimeoutTime ), sizeof( TickType_t ) ); - memset( &xAddress, 0, sizeof( xAddress ) ); + ( void ) memset( &xAddress, 0, sizeof( xAddress ) ); xAddress.sin_family = FREERTOS_AF_INET4; xAddress.sin_len = ( uint8_t ) sizeof( xAddress ); /* Bind to the standard DHCP client port. */ From 0b8454d9f15958a904b6053b97333cc19606371f Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Fri, 24 Nov 2023 08:08:25 +0000 Subject: [PATCH 10/19] MISRA fix 21.1 --- source/include/FreeRTOSIPConfigDefaults.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index 8e06a28171..34f048c744 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -67,6 +67,9 @@ */ #ifndef _static + /* suppressing the use of _static as it is used for other tools like cbmc */ + /* coverity[misra_c_2012_rule_21_1_violation] */ + /* coverity[misra_c_2012_rule_21_2_violation] */ #define _static static #endif From 45f8ed015f388f9ece325f2198109ab32304dfec Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Fri, 24 Nov 2023 10:01:17 +0000 Subject: [PATCH 11/19] MISRA fix 8.9 --- source/FreeRTOS_IPv6.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/FreeRTOS_IPv6.c b/source/FreeRTOS_IPv6.c index b021f3ef27..0e8f85ea19 100644 --- a/source/FreeRTOS_IPv6.c +++ b/source/FreeRTOS_IPv6.c @@ -62,6 +62,9 @@ const struct xIPv6_Address FreeRTOS_in6addr_any = { 0 }; /** * This variable is initialized by the system to contain the loopback IPv6 address. */ +/* MISRA Ref 8.9.1 [File scoped variables] */ +/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-89 */ +/* coverity[misra_c_2012_rule_8_9_violation] */ const struct xIPv6_Address FreeRTOS_in6addr_loopback = { { 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U } }; #if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 1 ) From 18b557c384ca9b9c05ef6ffbe66f5e4df92d9be2 Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Fri, 24 Nov 2023 10:18:42 +0000 Subject: [PATCH 12/19] MISRA fix 21.15 --- source/FreeRTOS_ARP.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index cc24dbfb79..43dc34fe7f 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -294,8 +294,8 @@ static TickType_t xLastGratuitousARPTime = 0U; if( ulTargetProtocolAddress == pxTargetEndPoint->ipv4_settings.ulIPAddress ) { - if( memcmp( ( void * ) pxTargetEndPoint->xMACAddress.ucBytes, - ( pxARPHeader->xSenderHardwareAddress.ucBytes ), + if( memcmp( pxTargetEndPoint->xMACAddress.ucBytes, + pxARPHeader->xSenderHardwareAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) != 0 ) { vARPProcessPacketRequest( pxARPFrame, pxTargetEndPoint, ulSenderProtocolAddress ); @@ -310,9 +310,9 @@ static TickType_t xLastGratuitousARPTime = 0U; /* Make sure target MAC address is either ff:ff:ff:ff:ff:ff or 00:00:00:00:00:00 and senders MAC * address is not matching with the endpoint MAC address. */ - if( ( ( memcmp( ( const void * ) pxARPHeader->xTargetHardwareAddress.ucBytes, xBroadcastMACAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) || - ( ( memcmp( ( const void * ) pxARPHeader->xTargetHardwareAddress.ucBytes, xGARPTargetAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ) ) && - ( memcmp( ( void * ) pxTargetEndPoint->xMACAddress.ucBytes, ( pxARPHeader->xSenderHardwareAddress.ucBytes ), ipMAC_ADDRESS_LENGTH_BYTES ) != 0 ) ) + if( ( ( memcmp( pxARPHeader->xTargetHardwareAddress.ucBytes, xBroadcastMACAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) || + ( ( memcmp( pxARPHeader->xTargetHardwareAddress.ucBytes, xGARPTargetAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 ) ) ) && + ( memcmp( pxTargetEndPoint->xMACAddress.ucBytes, pxARPHeader->xSenderHardwareAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) != 0 ) ) { MACAddress_t xHardwareAddress; NetworkEndPoint_t * pxCachedEndPoint; From aa25f936d29071cd32d19b84ff9bb76d4537d87b Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Wed, 29 Nov 2023 11:05:35 +0000 Subject: [PATCH 13/19] MISRA fix 15.6 --- source/include/FreeRTOSIPConfigDefaults.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index 34f048c744..bcd640bb94 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -3122,7 +3122,13 @@ */ #ifndef FreeRTOS_flush_logging - #define FreeRTOS_flush_logging() if( ipconfigHAS_PRINTF || ipconfigHAS_DEBUG_PRINTF ) do {} while( ipFALSE_BOOL ) + #define FreeRTOS_flush_logging() if( ipconfigHAS_PRINTF || ipconfigHAS_DEBUG_PRINTF ) \ + { \ + do {} while( ipFALSE_BOOL ); \ + } \ + else \ + { \ + } #endif /*---------------------------------------------------------------------------*/ From 7c40f8579ce64bb41c371200330b54146602b0e7 Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Wed, 29 Nov 2023 07:12:29 +0000 Subject: [PATCH 14/19] Fix MISRA 9.1 --- source/FreeRTOS_Sockets.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index 894a901467..cd76296156 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -1926,8 +1926,16 @@ BaseType_t vSocketBind( FreeRTOS_Socket_t * pxSocket, if( pxAddress == NULL ) { pxAddress = &xAddress; - /* Put the port to zero to be assigned later. */ - pxAddress->sin_port = 0U; + /* Clear the address: */ + ( void ) memset( pxAddress, 0, sizeof( struct freertos_sockaddr ) ); + if( pxSocket->bits.bIsIPv6 == pdFALSE_UNSIGNED ) + { + pxAddress->sin_family = FREERTOS_AF_INET6; + } + else + { + pxAddress->sin_family = FREERTOS_AF_INET; + } } } #endif /* ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND == 1 */ From e65e44fec7980976bb16690971d1e9e6a573399d Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 29 Nov 2023 16:10:27 +0000 Subject: [PATCH 15/19] Uncrustify: triggered by comment. --- source/FreeRTOS_Sockets.c | 1 + source/include/FreeRTOSIPConfigDefaults.h | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index cd76296156..672680ee74 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -1928,6 +1928,7 @@ BaseType_t vSocketBind( FreeRTOS_Socket_t * pxSocket, pxAddress = &xAddress; /* Clear the address: */ ( void ) memset( pxAddress, 0, sizeof( struct freertos_sockaddr ) ); + if( pxSocket->bits.bIsIPv6 == pdFALSE_UNSIGNED ) { pxAddress->sin_family = FREERTOS_AF_INET6; diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index bcd640bb94..0b9c2d90ab 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -3122,13 +3122,14 @@ */ #ifndef FreeRTOS_flush_logging - #define FreeRTOS_flush_logging() if( ipconfigHAS_PRINTF || ipconfigHAS_DEBUG_PRINTF ) \ - { \ - do {} while( ipFALSE_BOOL ); \ - } \ - else \ - { \ - } + #define FreeRTOS_flush_logging() \ + if( ipconfigHAS_PRINTF || ipconfigHAS_DEBUG_PRINTF ) \ + { \ + do {} while( ipFALSE_BOOL ); \ + } \ + else \ + { \ + } #endif /*---------------------------------------------------------------------------*/ From 7048c5d6b47ae1c05f59949a02cc6f709f89231b Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Wed, 29 Nov 2023 18:02:14 +0000 Subject: [PATCH 16/19] Fix build issue --- source/include/FreeRTOSIPConfigDefaults.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index 0b9c2d90ab..49b47e7131 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -3067,7 +3067,7 @@ #ifndef FreeRTOS_debug_printf #ifdef configPRINTF - #define FreeRTOS_debug_printf( MSG ) if( ipconfigHAS_DEBUG_PRINTF ) { configPRINTF( MSG ) } + #define FreeRTOS_debug_printf( MSG ) if( ipconfigHAS_DEBUG_PRINTF ) { configPRINTF( MSG ); } #else #define FreeRTOS_debug_printf( MSG ) do {} while( ipFALSE_BOOL ) #endif @@ -3103,7 +3103,7 @@ #ifndef FreeRTOS_printf #ifdef configPRINTF - #define FreeRTOS_printf( MSG ) if( ipconfigHAS_PRINTF ) { configPRINTF( MSG ) } + #define FreeRTOS_printf( MSG ) if( ipconfigHAS_PRINTF ) { configPRINTF( MSG ); } #else #define FreeRTOS_printf( MSG ) do {} while( ipFALSE_BOOL ) #endif From 9b7a03c8ace9142f82039e8413f442f5688b9535 Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Thu, 30 Nov 2023 05:45:36 +0000 Subject: [PATCH 17/19] Fix review comments --- source/FreeRTOS_DNS.c | 2 +- source/FreeRTOS_Sockets.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/FreeRTOS_DNS.c b/source/FreeRTOS_DNS.c index 5044edb4c1..9dc3832b13 100644 --- a/source/FreeRTOS_DNS.c +++ b/source/FreeRTOS_DNS.c @@ -1082,7 +1082,7 @@ /* 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 DNSMessage_t * pxDNSMessageHeader = ( ( const DNSMessage_t * ) pxReceiveBuffer->pucPayloadBuffer ); + const DNSMessage_t * pxDNSMessageHeader = ( const DNSMessage_t * ) pxReceiveBuffer->pucPayloadBuffer; #if ( ipconfigUSE_MDNS == 1 ) /* _HT_ changed 'pxReceiveBuffer->sin_port' to 'usPort' */ diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index 672680ee74..ef07f43350 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -1929,7 +1929,7 @@ BaseType_t vSocketBind( FreeRTOS_Socket_t * pxSocket, /* Clear the address: */ ( void ) memset( pxAddress, 0, sizeof( struct freertos_sockaddr ) ); - if( pxSocket->bits.bIsIPv6 == pdFALSE_UNSIGNED ) + if( pxSocket->bits.bIsIPv6 != pdFALSE_UNSIGNED ) { pxAddress->sin_family = FREERTOS_AF_INET6; } From 8aa068ae6ed1f1533b6777d079a60e1b20f1f60e Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Tue, 5 Dec 2023 11:28:46 +0000 Subject: [PATCH 18/19] Fix MISRA 14.4 - The condition expression 0 does not have an essentially boolean type --- source/include/FreeRTOSIPConfigDefaults.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index 49b47e7131..70406fa225 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -3066,8 +3066,8 @@ #endif #ifndef FreeRTOS_debug_printf - #ifdef configPRINTF - #define FreeRTOS_debug_printf( MSG ) if( ipconfigHAS_DEBUG_PRINTF ) { configPRINTF( MSG ); } + #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( configPRINTF ) ) + #define FreeRTOS_debug_printf( MSG ) do { configPRINTF( MSG ); } while( ipFALSE_BOOL ) #else #define FreeRTOS_debug_printf( MSG ) do {} while( ipFALSE_BOOL ) #endif @@ -3102,8 +3102,8 @@ #endif #ifndef FreeRTOS_printf - #ifdef configPRINTF - #define FreeRTOS_printf( MSG ) if( ipconfigHAS_PRINTF ) { configPRINTF( MSG ); } + #if ( ( ipconfigHAS_PRINTF == 1 ) && defined( configPRINTF ) ) + #define FreeRTOS_printf( MSG ) do { configPRINTF( MSG ); } while( ipFALSE_BOOL ) #else #define FreeRTOS_printf( MSG ) do {} while( ipFALSE_BOOL ) #endif From a2809ea5eb67f4f3a1634c49c0b4550a4c3856bc Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Thu, 7 Dec 2023 15:31:39 +0000 Subject: [PATCH 19/19] Fix cbmc --- test/cbmc/patches/FreeRTOSIPConfig.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/cbmc/patches/FreeRTOSIPConfig.h b/test/cbmc/patches/FreeRTOSIPConfig.h index 03d9164d62..f94bfb655a 100644 --- a/test/cbmc/patches/FreeRTOSIPConfig.h +++ b/test/cbmc/patches/FreeRTOSIPConfig.h @@ -37,12 +37,7 @@ /* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to * 1 then FreeRTOS_debug_printf should be defined to the function used to print * out the debugging messages. */ -#ifndef ipconfigHAS_DEBUG_PRINTF - #define ipconfigHAS_DEBUG_PRINTF 0 -#endif -#if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - #define FreeRTOS_debug_printf( X ) configPRINTF( X ) -#endif +#define FreeRTOS_debug_printf( X ) /* Set to 1 to print out non debugging messages, for example the output of the * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1