diff options
author | Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> | 2020-08-28 15:14:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-28 15:14:37 -0700 |
commit | 3fc432f7beb830cfab5bad5ae0e4f52a1ea59ce7 (patch) | |
tree | c984291c8d78f135f5b29ef28129559d7e81447d | |
parent | 66371d0cf0dcbc4df8a8101d9d1b67b3efd9e786 (diff) | |
download | freertos-git-3fc432f7beb830cfab5bad5ae0e4f52a1ea59ce7.tar.gz |
TCP: Address MISRA rule11.3 violations (#225)
6 files changed, 222 insertions, 89 deletions
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c index 9104a7236..e86e7e61a 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c @@ -656,7 +656,7 @@ ARPPacket_t *pxARPPacket; configASSERT( pxNetworkBuffer != NULL ); configASSERT( pxNetworkBuffer->xDataLength >= sizeof(ARPPacket_t) ); - pxARPPacket = ipPOINTER_CAST( ARPPacket_t *, pxNetworkBuffer->pucEthernetBuffer ); + pxARPPacket = ipCAST_PTR_TO_TYPE_PTR( ARPPacket_t, pxNetworkBuffer->pucEthernetBuffer ); /* memcpy the const part of the header information into the correct location in the packet. This copies: @@ -693,7 +693,7 @@ BaseType_t xCheckLoopback( NetworkBufferDescriptor_t * const pxDescriptor, BaseT { BaseType_t xResult = pdFALSE; NetworkBufferDescriptor_t * pxUseDescriptor = pxDescriptor; -const IPPacket_t *pxIPPacket = ipPOINTER_CAST( IPPacket_t *, pxUseDescriptor->pucEthernetBuffer ); +const IPPacket_t *pxIPPacket = ipCAST_PTR_TO_TYPE_PTR( IPPacket_t, pxUseDescriptor->pucEthernetBuffer ); /* This function will check if the target IP-address belongs to this device. * If so, the packet will be passed to the IP-stack, who will answer it. diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DHCP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DHCP.c index e12db9162..b0b0687bf 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DHCP.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DHCP.c @@ -154,6 +154,16 @@ struct xDHCPMessage_IPv4 #include "pack_struct_end.h" typedef struct xDHCPMessage_IPv4 DHCPMessage_IPv4_t; +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DHCPMessage_IPv4_t ) +{ + return ( DHCPMessage_IPv4_t *)pvArgument; +} +static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( DHCPMessage_IPv4_t ) +{ + return ( const DHCPMessage_IPv4_t *) pvArgument; +} + + /* The UDP socket used for all incoming and outgoing DHCP traffic. */ _static Socket_t xDHCPSocket; @@ -639,7 +649,7 @@ const uint32_t ulMandatoryOptions = 2UL; /* DHCP server address, and the correct if( lBytes > 0 ) { /* Map a DHCP structure onto the received data. */ - pxDHCPMessage = ipPOINTER_CAST( const DHCPMessage_IPv4_t *, pucUDPPayload ); + pxDHCPMessage = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( DHCPMessage_IPv4_t, pucUDPPayload ); /* Sanity check. */ if( lBytes < ( int32_t ) sizeof( DHCPMessage_IPv4_t ) ) @@ -887,7 +897,7 @@ uint8_t *pucUDPPayloadBuffer; /* Leave space for the UPD header. */ pucUDPPayloadBuffer = &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] ); - pxDHCPMessage = ipPOINTER_CAST( DHCPMessage_IPv4_t *, pucUDPPayloadBuffer ); + pxDHCPMessage = ipCAST_PTR_TO_TYPE_PTR( DHCPMessage_IPv4_t, pucUDPPayloadBuffer ); /* Most fields need to be zero. */ ( void ) memset( pxDHCPMessage, 0x00, sizeof( DHCPMessage_IPv4_t ) ); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DNS.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DNS.c index ca9a7bd90..a24bcb507 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DNS.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DNS.c @@ -250,16 +250,14 @@ struct xDNSMessage #include "pack_struct_end.h" typedef struct xDNSMessage DNSMessage_t; - static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSMessage_t ) - { - /* coverity[misra_c_2012_rule_11_3_violation] */ - return ( DNSMessage_t *)pvArgument; - } - static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( DNSMessage_t ) - { - /* coverity[misra_c_2012_rule_11_3_violation] */ - return ( const DNSMessage_t *) pvArgument; - } +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSMessage_t ) +{ + return ( DNSMessage_t *)pvArgument; +} +static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( DNSMessage_t ) +{ + return ( const DNSMessage_t *) pvArgument; +} /* A DNS query consists of a header, as described in 'struct xDNSMessage' It is followed by 1 or more queries, each one consisting of a name and a tail, @@ -274,11 +272,10 @@ struct xDNSTail #include "pack_struct_end.h" typedef struct xDNSTail DNSTail_t; - static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSTail_t ) - { - /* coverity[misra_c_2012_rule_11_3_violation] */ - return ( DNSTail_t * ) pvArgument; - } +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSTail_t ) +{ + return ( DNSTail_t * ) pvArgument; +} /* DNS answer record header. */ #include "pack_struct_start.h" @@ -292,11 +289,10 @@ struct xDNSAnswerRecord #include "pack_struct_end.h" typedef struct xDNSAnswerRecord DNSAnswerRecord_t; - static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSAnswerRecord_t ) - { - /* coverity[misra_c_2012_rule_11_3_violation] */ - return ( DNSAnswerRecord_t * ) pvArgument; - } +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSAnswerRecord_t ) +{ + return ( DNSAnswerRecord_t * ) pvArgument; +} #if( ipconfigUSE_LLMNR == 1 ) @@ -314,6 +310,12 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t; #include "pack_struct_end.h" typedef struct xLLMNRAnswer LLMNRAnswer_t; + static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( LLMNRAnswer_t ) + { + return ( LLMNRAnswer_t *)pvArgument; + } + + #endif /* ipconfigUSE_LLMNR == 1 */ #if( ipconfigUSE_NBNS == 1 ) @@ -349,6 +351,11 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t; #include "pack_struct_end.h" typedef struct xNBNSAnswer NBNSAnswer_t; + static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( NBNSAnswer_t ) + { + return ( NBNSAnswer_t *)pvArgument; + } + #endif /* ipconfigUSE_NBNS == 1 */ /*-----------------------------------------------------------*/ @@ -376,6 +383,11 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t; char pcName[ 1 ]; } DNSCallback_t; + static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( DNSCallback_t ) + { + return ( DNSCallback_t *)pvArgument; + } + static List_t xCallbackList; /* Define FreeRTOS_gethostbyname() as a normal blocking call. */ @@ -408,7 +420,7 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t; pxIterator != xEnd; ) { - DNSCallback_t *pxCallback = ipPOINTER_CAST( DNSCallback_t *, listGET_LIST_ITEM_OWNER( pxIterator ) ); + DNSCallback_t *pxCallback = ipCAST_PTR_TO_TYPE_PTR( DNSCallback_t, listGET_LIST_ITEM_OWNER( pxIterator ) ); /* Move to the next item because we might remove this item */ pxIterator = ( const ListItem_t * ) listGET_NEXT( pxIterator ); if( ( pvSearchID != NULL ) && ( pvSearchID == pxCallback->pvSearchID ) ) @@ -453,7 +465,7 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t; TickType_t uxIdentifier ) { size_t lLength = strlen( pcHostName ); - DNSCallback_t *pxCallback = ipPOINTER_CAST( DNSCallback_t *, pvPortMalloc( sizeof( *pxCallback ) + lLength ) ); + DNSCallback_t *pxCallback = ipCAST_PTR_TO_TYPE_PTR( DNSCallback_t, pvPortMalloc( sizeof( *pxCallback ) + lLength ) ); /* Translate from ms to number of clock ticks. */ uxTimeout /= portTICK_PERIOD_MS; @@ -471,7 +483,7 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t; pxCallback->pvSearchID = pvSearchID; pxCallback->uxRemaningTime = uxTimeout; vTaskSetTimeOutState( &pxCallback->uxTimeoutState ); - listSET_LIST_ITEM_OWNER( &( pxCallback->xListItem ), ipPOINTER_CAST( void *, pxCallback ) ); + listSET_LIST_ITEM_OWNER( &( pxCallback->xListItem ), ( void *) pxCallback ); listSET_LIST_ITEM_VALUE( &( pxCallback->xListItem ), uxIdentifier ); vTaskSuspendAll(); { @@ -500,7 +512,7 @@ typedef struct xDNSAnswerRecord DNSAnswerRecord_t; { if( listGET_LIST_ITEM_VALUE( pxIterator ) == uxIdentifier ) { - DNSCallback_t *pxCallback = ipPOINTER_CAST( DNSCallback_t *, listGET_LIST_ITEM_OWNER( pxIterator ) ); + DNSCallback_t *pxCallback = ipCAST_PTR_TO_TYPE_PTR( DNSCallback_t, listGET_LIST_ITEM_OWNER( pxIterator ) ); pxCallback->pCallbackFunction( pcName, pxCallback->pvSearchID, ulIPAddress ); ( void ) uxListRemove( &pxCallback->xListItem ); @@ -1415,7 +1427,7 @@ BaseType_t xReturn = pdTRUE; /* The test on 'pucNewBuffer' is only to satisfy lint. */ if( ( pxNetworkBuffer != NULL ) && ( pucNewBuffer != NULL ) ) { - pxAnswer = ipPOINTER_CAST( LLMNRAnswer_t *, pucByte ); + pxAnswer = ipCAST_PTR_TO_TYPE_PTR( LLMNRAnswer_t, pucByte ); /* We leave 'usIdentifier' and 'usQuestions' untouched */ #ifndef _lint @@ -1604,8 +1616,8 @@ BaseType_t xReturn = pdTRUE; #else ( void ) pxMessage; #endif - - pxAnswer = ipPOINTER_CAST( NBNSAnswer_t *, &( pucUDPPayloadBuffer[ offsetof( NBNSRequest_t, usType ) ] ) ); + + pxAnswer = ipCAST_PTR_TO_TYPE_PTR( NBNSAnswer_t, &( pucUDPPayloadBuffer[ offsetof( NBNSRequest_t, usType ) ] ) ); #ifndef _lint vSetField16( pxAnswer, NBNSAnswer_t, usType, usType ); /* Type */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c index bfd2a9c15..5dff8ef4a 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c @@ -158,6 +158,16 @@ typedef union _xUnionPtr uint8_t *u8ptr; } xUnionPtr; + +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( NetworkBufferDescriptor_t ) +{ + return ( NetworkBufferDescriptor_t *)pvArgument; +} +static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( NetworkBufferDescriptor_t ) +{ + return ( const NetworkBufferDescriptor_t *) pvArgument; +} + /*-----------------------------------------------------------*/ /* @@ -362,7 +372,7 @@ struct freertos_sockaddr xAddress; /* Wait until there is something to do. If the following call exits * due to a time out rather than a message being received, set a * 'NoEvent' value. */ - if ( xQueueReceive( xNetworkEventQueue, ipPOINTER_CAST( void *, &xReceivedEvent ), xNextIPSleep ) == pdFALSE ) + if ( xQueueReceive( xNetworkEventQueue, ( void *) &xReceivedEvent, xNextIPSleep ) == pdFALSE ) { xReceivedEvent.eEventType = eNoEvent; } @@ -395,14 +405,14 @@ struct freertos_sockaddr xAddress; case eNetworkRxEvent: /* The network hardware driver has received a new packet. A pointer to the received buffer is located in the pvData member - of the received event structure. */ - prvHandleEthernetPacket( ipPOINTER_CAST( NetworkBufferDescriptor_t *, xReceivedEvent.pvData ) ); + of the received event structure. */ + prvHandleEthernetPacket( ipCAST_PTR_TO_TYPE_PTR( NetworkBufferDescriptor_t, xReceivedEvent.pvData ) ); break; case eNetworkTxEvent: /* Send a network packet. The ownership will be transferred to the driver, which will release it after delivery. */ - ( void ) xNetworkInterfaceOutput( ipPOINTER_CAST( NetworkBufferDescriptor_t *, xReceivedEvent.pvData ), pdTRUE ); + ( void ) xNetworkInterfaceOutput( ipCAST_PTR_TO_TYPE_PTR( NetworkBufferDescriptor_t, xReceivedEvent.pvData ), pdTRUE ); break; case eARPTimerEvent : @@ -416,7 +426,7 @@ struct freertos_sockaddr xAddress; usLocalPort. vSocketBind() will actually bind the socket and the API will unblock as soon as the eSOCKET_BOUND event is triggered. */ - pxSocket = ipPOINTER_CAST( FreeRTOS_Socket_t *, xReceivedEvent.pvData ); + pxSocket = ipCAST_PTR_TO_TYPE_PTR( FreeRTOS_Socket_t, xReceivedEvent.pvData ); xAddress.sin_addr = 0U; /* For the moment. */ xAddress.sin_port = FreeRTOS_ntohs( pxSocket->usLocalPort ); pxSocket->usLocalPort = 0U; @@ -434,14 +444,14 @@ struct freertos_sockaddr xAddress; IP-task to actually close a socket. This is handled in vSocketClose(). As the socket gets closed, there is no way to report back to the API, so the API won't wait for the result */ - ( void ) vSocketClose( ipPOINTER_CAST( FreeRTOS_Socket_t *, xReceivedEvent.pvData ) ); + ( void ) vSocketClose( ipCAST_PTR_TO_TYPE_PTR( FreeRTOS_Socket_t, xReceivedEvent.pvData ) ); break; case eStackTxEvent : /* The network stack has generated a packet to send. A pointer to the generated buffer is located in the pvData member of the received event structure. */ - vProcessGeneratedUDPPacket( ipPOINTER_CAST( NetworkBufferDescriptor_t *, xReceivedEvent.pvData ) ); + vProcessGeneratedUDPPacket( ipCAST_PTR_TO_TYPE_PTR( NetworkBufferDescriptor_t, xReceivedEvent.pvData ) ); break; case eDHCPEvent: @@ -462,13 +472,13 @@ struct freertos_sockaddr xAddress; { #if( ipconfigSELECT_USES_NOTIFY != 0 ) { - SocketSelectMessage_t *pxMessage = ipPOINTER_CAST( SocketSelectMessage_t *, xReceivedEvent.pvData ); + SocketSelectMessage_t *pxMessage = ipCAST_PTR_TO_TYPE_PTR( SocketSelectMessage_t, xReceivedEvent.pvData ); vSocketSelect( pxMessage->pxSocketSet ); ( void ) xTaskNotifyGive( pxMessage->xTaskhandle ); } #else - { - vSocketSelect( ipPOINTER_CAST( SocketSelect_t *, xReceivedEvent.pvData ) ); + { + vSocketSelect( ipCAST_PTR_TO_TYPE_PTR( SocketSelect_t, xReceivedEvent.pvData ) ); } #endif /* ( ipconfigSELECT_USES_NOTIFY != 0 ) */ } @@ -501,7 +511,7 @@ struct freertos_sockaddr xAddress; received a new connection. */ #if( ipconfigUSE_TCP == 1 ) { - pxSocket = ipPOINTER_CAST( FreeRTOS_Socket_t *, xReceivedEvent.pvData ); + pxSocket = ipCAST_PTR_TO_TYPE_PTR( FreeRTOS_Socket_t, xReceivedEvent.pvData ); if( xTCPCheckNewClient( pxSocket ) != pdFALSE ) { @@ -1153,11 +1163,10 @@ void FreeRTOS_SetAddressConfiguration( const uint32_t *pulIPAddress, } if( ( uxGetNumberOfFreeNetworkBuffers() >= 3U ) && ( uxNumberOfBytesToSend >= 1U ) && ( xEnoughSpace != pdFALSE ) ) { - pxEthernetHeader = ipPOINTER_CAST( EthernetHeader_t *, pxNetworkBuffer->pucEthernetBuffer ); + pxEthernetHeader = ipCAST_PTR_TO_TYPE_PTR( EthernetHeader_t, pxNetworkBuffer->pucEthernetBuffer ); pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; - - pxICMPHeader = ipPOINTER_CAST( ICMPHeader_t *, &( pxNetworkBuffer->pucEthernetBuffer[ ipIP_PAYLOAD_OFFSET ] ) ); + pxICMPHeader = ipCAST_PTR_TO_TYPE_PTR( ICMPHeader_t, &( pxNetworkBuffer->pucEthernetBuffer[ ipIP_PAYLOAD_OFFSET ] ) ); usSequenceNumber++; /* Fill in the basic header information. */ @@ -1289,7 +1298,7 @@ eFrameProcessingResult_t eReturn; const EthernetHeader_t *pxEthernetHeader; /* Map the buffer onto Ethernet Header struct for easy access to fields. */ - pxEthernetHeader = ipPOINTER_CAST( const EthernetHeader_t *, pucEthernetBuffer ); + pxEthernetHeader = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( EthernetHeader_t, pucEthernetBuffer ); if( memcmp( ipLOCAL_MAC_ADDRESS, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) { @@ -1430,7 +1439,7 @@ eFrameProcessingResult_t eReturned = eReleaseBuffer; eReturned = ipCONSIDER_FRAME_FOR_PROCESSING( pxNetworkBuffer->pucEthernetBuffer ); /* Map the buffer onto the Ethernet Header struct for easy access to the fields. */ - pxEthernetHeader = ipPOINTER_CAST( const EthernetHeader_t *, pxNetworkBuffer->pucEthernetBuffer ); + pxEthernetHeader = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( EthernetHeader_t, pxNetworkBuffer->pucEthernetBuffer ); /* The condition "eReturned == eProcessBuffer" must be true. */ #if( ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES == 0 ) @@ -1444,7 +1453,7 @@ eFrameProcessingResult_t eReturned = eReleaseBuffer; /* The Ethernet frame contains an ARP packet. */ if( pxNetworkBuffer->xDataLength >= sizeof( ARPPacket_t ) ) { - eReturned = eARPProcessPacket( ipPOINTER_CAST( ARPPacket_t *, pxNetworkBuffer->pucEthernetBuffer ) ); + eReturned = eARPProcessPacket( ipCAST_PTR_TO_TYPE_PTR( ARPPacket_t, pxNetworkBuffer->pucEthernetBuffer ) ); } else { @@ -1456,7 +1465,7 @@ eFrameProcessingResult_t eReturned = eReleaseBuffer; /* The Ethernet frame contains an IP packet. */ if( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_t ) ) { - eReturned = prvProcessIPPacket( ipPOINTER_CAST( IPPacket_t *, pxNetworkBuffer->pucEthernetBuffer ), pxNetworkBuffer ); + eReturned = prvProcessIPPacket( ipCAST_PTR_TO_TYPE_PTR( IPPacket_t, pxNetworkBuffer->pucEthernetBuffer ), pxNetworkBuffer ); } else { @@ -1643,7 +1652,7 @@ eFrameProcessingResult_t eReturn = eProcessBuffer; const uint16_t *pusChecksum; /* pxProtPack will point to the offset were the protocols begin. */ - pxProtPack = ipPOINTER_CAST( ProtocolPacket_t *, &( pxNetworkBuffer->pucEthernetBuffer[ uxHeaderLength - ipSIZE_OF_IPv4_HEADER ] ) ); + pxProtPack = ipCAST_PTR_TO_TYPE_PTR( ProtocolPacket_t, &( pxNetworkBuffer->pucEthernetBuffer[ uxHeaderLength - ipSIZE_OF_IPv4_HEADER ] ) ); pusChecksum = ( const uint16_t * ) ( &( pxProtPack->xUDPPacket.xUDPHeader.usChecksum ) ); if( *pusChecksum == ( uint16_t ) 0U ) { @@ -1762,7 +1771,7 @@ uint8_t ucProtocol; { /* Map the buffer onto a ICMP-Packet struct to easily access the * fields of ICMP packet. */ - ICMPPacket_t *pxICMPPacket = ipPOINTER_CAST( ICMPPacket_t *, pxNetworkBuffer->pucEthernetBuffer ); + ICMPPacket_t *pxICMPPacket = ipCAST_PTR_TO_TYPE_PTR( ICMPPacket_t, pxNetworkBuffer->pucEthernetBuffer ); if( pxIPHeader->ulDestinationIPAddress == *ipLOCAL_IP_ADDRESS_POINTER ) { eReturn = prvProcessICMPPacket( pxICMPPacket ); @@ -1782,7 +1791,7 @@ uint8_t ucProtocol; /* Map the buffer onto a UDP-Packet struct to easily access the * fields of UDP packet. */ - const UDPPacket_t *pxUDPPacket = ipPOINTER_CAST( const UDPPacket_t *, pxNetworkBuffer->pucEthernetBuffer ); + const UDPPacket_t *pxUDPPacket = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( UDPPacket_t, pxNetworkBuffer->pucEthernetBuffer ); uint16_t usLength; /* Note the header values required prior to the checksum @@ -2010,7 +2019,7 @@ uint8_t ucProtocol; /* Map the buffer onto a IP-Packet struct to easily access the * fields of the IP packet. */ - pxIPPacket = ipPOINTER_CAST( const IPPacket_t *, pucEthernetBuffer ); + pxIPPacket = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( IPPacket_t, pucEthernetBuffer ); ucVersionHeaderLength = pxIPPacket->xIPHeader.ucVersionHeaderLength; /* Test if the length of the IP-header is between 20 and 60 bytes, @@ -2049,7 +2058,7 @@ uint8_t ucProtocol; of this calculation. */ /* Map the Buffer onto the Protocol Packet struct for easy access to the * struct fields. */ - pxProtPack = ipPOINTER_CAST( ProtocolPacket_t *, &( pucEthernetBuffer[ uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ] ) ); + pxProtPack = ipCAST_PTR_TO_TYPE_PTR( ProtocolPacket_t, &( pucEthernetBuffer[ uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ] ) ); /* Switch on the Layer 3/4 protocol. */ if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) @@ -2133,7 +2142,7 @@ BaseType_t location = 0; } /* Parse the packet length. */ - pxIPPacket = ipPOINTER_CAST( const IPPacket_t *, pucEthernetBuffer ); + pxIPPacket = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( IPPacket_t, pucEthernetBuffer ); /* Per https://tools.ietf.org/html/rfc791, the four-bit Internet Header Length field contains the length of the internet header in 32-bit words. */ @@ -2165,7 +2174,7 @@ BaseType_t location = 0; and IP headers incorrectly aligned. However, either way, the "third" protocol (Layer 3 or 4) header will be aligned, which is the convenience of this calculation. */ - pxProtPack = ipPOINTER_CAST( ProtocolPacket_t *, &( pucEthernetBuffer[ uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ] ) ); + pxProtPack = ipCAST_PTR_TO_TYPE_PTR( ProtocolPacket_t, &( pucEthernetBuffer[ uxIPHeaderLength - ipSIZE_OF_IPv4_HEADER ] ) ); /* Switch on the Layer 3/4 protocol. */ if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) @@ -2578,7 +2587,7 @@ EthernetHeader_t *pxEthernetHeader; #endif { /* Map the Buffer to Ethernet Header struct for easy access to fields. */ - pxEthernetHeader = ipPOINTER_CAST( EthernetHeader_t *, pxNetworkBuffer->pucEthernetBuffer ); + pxEthernetHeader = ipCAST_PTR_TO_TYPE_PTR( EthernetHeader_t, pxNetworkBuffer->pucEthernetBuffer ); /* Swap source and destination MAC addresses. */ ( void ) memcpy( &( pxEthernetHeader->xDestinationAddress ), &( pxEthernetHeader->xSourceAddress ), sizeof( pxEthernetHeader->xDestinationAddress ) ); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c index 25d1dbd75..66275d7f4 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c @@ -87,7 +87,28 @@ range 1024-65535" excluding those already in use (inbound or outbound). */ #define sock80_PERCENT 80U #define sock100_PERCENT 100U +#if( ipconfigUSE_CALLBACKS != 0 ) + static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( F_TCP_UDP_Handler_t ) + { + return ( F_TCP_UDP_Handler_t *)pvArgument; + } + static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( F_TCP_UDP_Handler_t ) + { + return ( const F_TCP_UDP_Handler_t *) pvArgument; + } +#endif + +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( NetworkBufferDescriptor_t ) +{ + return ( NetworkBufferDescriptor_t *)pvArgument; +} + + +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( StreamBuffer_t ) +{ + return ( StreamBuffer_t *)pvArgument; +} /*-----------------------------------------------------------*/ /* @@ -294,7 +315,7 @@ Socket_t xReturn; size depends on the type of socket: UDP sockets need less space. A define 'pvPortMallocSocket' will used to allocate the necessary space. By default it points to the FreeRTOS function 'pvPortMalloc()'. */ - pxSocket = ipPOINTER_CAST( FreeRTOS_Socket_t *, pvPortMallocSocket( uxSocketSize ) ); + pxSocket = ipCAST_PTR_TO_TYPE_PTR( FreeRTOS_Socket_t, pvPortMallocSocket( uxSocketSize ) ); if( pxSocket == NULL ) { @@ -394,7 +415,7 @@ Socket_t xReturn; { SocketSelect_t *pxSocketSet; - pxSocketSet = ipPOINTER_CAST( SocketSelect_t *, pvPortMalloc( sizeof( *pxSocketSet ) ) ); + pxSocketSet = ipCAST_PTR_TO_TYPE_PTR( SocketSelect_t, pvPortMalloc( sizeof( *pxSocketSet ) ) ); if( pxSocketSet != NULL ) { @@ -733,7 +754,7 @@ EventBits_t xEventBits = ( EventBits_t ) 0; taskENTER_CRITICAL(); { /* The owner of the list item is the network buffer. */ - pxNetworkBuffer = ipPOINTER_CAST( NetworkBufferDescriptor_t *, listGET_OWNER_OF_HEAD_ENTRY( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) ); + pxNetworkBuffer = ipCAST_PTR_TO_TYPE_PTR( NetworkBufferDescriptor_t, listGET_OWNER_OF_HEAD_ENTRY( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) ); if( ( ( UBaseType_t ) xFlags & ( UBaseType_t ) FREERTOS_MSG_PEEK ) == 0U ) { @@ -1273,7 +1294,7 @@ NetworkBufferDescriptor_t *pxNetworkBuffer; { while( listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) > 0U ) { - pxNetworkBuffer = ipPOINTER_CAST( NetworkBufferDescriptor_t *, listGET_OWNER_OF_HEAD_ENTRY( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) ); + pxNetworkBuffer = ipCAST_PTR_TO_TYPE_PTR( NetworkBufferDescriptor_t, listGET_OWNER_OF_HEAD_ENTRY( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) ); ( void ) uxListRemove( &( pxNetworkBuffer->xBufferListItem ) ); vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); } @@ -1317,7 +1338,7 @@ NetworkBufferDescriptor_t *pxNetworkBuffer; static void prvTCPSetSocketCount( FreeRTOS_Socket_t const * pxSocketToDelete ) { const ListItem_t *pxIterator; - const ListItem_t *pxEnd = ipPOINTER_CAST( const ListItem_t *, listGET_END_MARKER( &xBoundTCPSocketsList ) ); + const ListItem_t *pxEnd = listGET_END_MARKER( &xBoundTCPSocketsList ); FreeRTOS_Socket_t *pxOtherSocket; uint16_t usLocalPort = pxSocketToDelete->usLocalPort; @@ -1325,7 +1346,7 @@ NetworkBufferDescriptor_t *pxNetworkBuffer; pxIterator != pxEnd; pxIterator = listGET_NEXT( pxIterator ) ) { - pxOtherSocket = ipPOINTER_CAST( FreeRTOS_Socket_t *, listGET_LIST_ITEM_OWNER( pxIterator ) ); + pxOtherSocket = ipCAST_PTR_TO_TYPE_PTR( FreeRTOS_Socket_t, listGET_LIST_ITEM_OWNER( pxIterator ) ); if( ( pxOtherSocket->u.xTCP.ucTCPState == ( uint8_t ) eTCP_LISTEN ) && ( pxOtherSocket->usLocalPort == usLocalPort ) && ( pxOtherSocket->u.xTCP.usChildCount != 0U ) ) @@ -1409,12 +1430,12 @@ FreeRTOS_Socket_t *pxSocket; { case FREERTOS_SO_RCVTIMEO : /* Receive time out. */ - pxSocket->xReceiveBlockTime = *( ipPOINTER_CAST( const TickType_t *, pvOptionValue ) ); + pxSocket->xReceiveBlockTime = *( ( TickType_t *) pvOptionValue ); xReturn = 0; break; case FREERTOS_SO_SNDTIMEO : - pxSocket->xSendBlockTime = *( ipPOINTER_CAST( const TickType_t *, pvOptionValue ) ); + pxSocket->xSendBlockTime = *( ( TickType_t *) pvOptionValue ); if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_UDP ) { /* The send time out is capped for the reason stated in the @@ -1498,20 +1519,20 @@ FreeRTOS_Socket_t *pxSocket; { #if ipconfigUSE_TCP == 1 case FREERTOS_SO_TCP_CONN_HANDLER: - pxSocket->u.xTCP.pxHandleConnected = ipPOINTER_CAST( const F_TCP_UDP_Handler_t *, pvOptionValue )->pxOnTCPConnected; + pxSocket->u.xTCP.pxHandleConnected = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( F_TCP_UDP_Handler_t, pvOptionValue )->pxOnTCPConnected; break; case FREERTOS_SO_TCP_RECV_HANDLER: - pxSocket->u.xTCP.pxHandleReceive = ipPOINTER_CAST( const F_TCP_UDP_Handler_t *, pvOptionValue )->pxOnTCPReceive; + pxSocket->u.xTCP.pxHandleReceive = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( F_TCP_UDP_Handler_t, pvOptionValue )->pxOnTCPReceive; break; case FREERTOS_SO_TCP_SENT_HANDLER: - pxSocket->u.xTCP.pxHandleSent = ipPOINTER_CAST( const F_TCP_UDP_Handler_t *, pvOptionValue )->pxOnTCPSent; + pxSocket->u.xTCP.pxHandleSent = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( F_TCP_UDP_Handler_t, pvOptionValue )->pxOnTCPSent; break; #endif /* ipconfigUSE_TCP */ case FREERTOS_SO_UDP_RECV_HANDLER: - pxSocket->u.xUDP.pxHandleReceive = ipPOINTER_CAST( const F_TCP_UDP_Handler_t *, pvOptionValue )->pxOnUDPReceive; + pxSocket->u.xUDP.pxHandleReceive = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( F_TCP_UDP_Handler_t, pvOptionValue )->pxOnUDPReceive; break; case FREERTOS_SO_UDP_SENT_HANDLER: - pxSocket->u.xUDP.pxHandleSent = ipPOINTER_CAST( const F_TCP_UDP_Handler_t *, pvOptionValue )->pxOnUDPSent; + pxSocket->u.xUDP.pxHandleSent = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( F_TCP_UDP_Handler_t, pvOptionValue )->pxOnUDPSent; break; default: /* Should it throw an error here? */ @@ -1640,7 +1661,7 @@ FreeRTOS_Socket_t *pxSocket; { break; /* will return -pdFREERTOS_ERRNO_EINVAL */ } - if( *( ipPOINTER_CAST( const BaseType_t *, pvOptionValue ) ) != 0 ) + if( *( ( BaseType_t * ) pvOptionValue ) != 0 ) { pxSocket->u.xTCP.bits.bReuseSocket = pdTRUE; } @@ -1659,7 +1680,7 @@ FreeRTOS_Socket_t *pxSocket; break; /* will return -pdFREERTOS_ERRNO_EINVAL */ } - if( *( ipPOINTER_CAST( const BaseType_t *, pvOptionValue ) ) != 0 ) + if( *( ( BaseType_t * ) pvOptionValue ) != 0 ) { pxSocket->u.xTCP.bits.bCloseAfterSend = pdTRUE; } @@ -1678,7 +1699,7 @@ FreeRTOS_Socket_t *pxSocket; break; /* will return -pdFREERTOS_ERRNO_EINVAL */ } - if( *( ipPOINTER_CAST( const BaseType_t *, pvOptionValue ) ) != 0 ) + if( *( ( BaseType_t *) pvOptionValue ) != 0 ) { pxSocket->u.xTCP.xTCPWindow.u.bits.bSendFullSize = pdTRUE; } @@ -1704,7 +1725,7 @@ FreeRTOS_Socket_t *pxSocket; { break; /* will return -pdFREERTOS_ERRNO_EINVAL */ } - if( *( ipPOINTER_CAST( const BaseType_t *, pvOptionValue ) ) != 0 ) + if( *( ( BaseType_t * ) pvOptionValue ) != 0 ) { pxSocket->u.xTCP.bits.bRxStopped = pdTRUE; } @@ -1803,7 +1824,7 @@ const ListItem_t * pxResult = NULL; if( ( xIPIsNetworkTaskReady() != pdFALSE ) && ( pxList != NULL ) ) { const ListItem_t *pxIterator; - const ListItem_t *pxEnd = ipPOINTER_CAST( const ListItem_t*, listGET_END_MARKER( pxList ) ); + const ListItem_t *pxEnd = listGET_END_MARKER( pxList ); for( pxIterator = listGET_NEXT( pxEnd ); pxIterator != pxEnd; pxIterator = listGET_NEXT( pxIterator ) ) @@ -1835,7 +1856,7 @@ FreeRTOS_Socket_t *pxSocket = NULL; if( pxListItem != NULL ) { /* The owner of the list item is the socket itself. */ - pxSocket = ipPOINTER_CAST( FreeRTOS_Socket_t *, listGET_LIST_ITEM_OWNER( pxListItem ) ); + pxSocket = ipCAST_PTR_TO_TYPE_PTR( FreeRTOS_Socket_t, listGET_LIST_ITEM_OWNER( pxListItem ) ); configASSERT( pxSocket != NULL ); } return pxSocket; @@ -3058,7 +3079,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket ) TickType_t xNow = xTaskGetTickCount(); static TickType_t xLastTime = 0U; TickType_t xDelta = xNow - xLastTime; - const ListItem_t* pxEnd = ipPOINTER_CAST( const ListItem_t *, listGET_END_MARKER( &xBoundTCPSocketsList ) ); + const ListItem_t* pxEnd = listGET_END_MARKER( &xBoundTCPSocketsList ); const ListItem_t *pxIterator = ( const ListItem_t * ) listGET_HEAD_ENTRY( &xBoundTCPSocketsList ); xLastTime = xNow; @@ -3070,7 +3091,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket ) while( pxIterator != pxEnd ) { - pxSocket = ipPOINTER_CAST( FreeRTOS_Socket_t *, listGET_LIST_ITEM_OWNER( pxIterator ) ); + pxSocket = ipCAST_PTR_TO_TYPE_PTR( FreeRTOS_Socket_t, listGET_LIST_ITEM_OWNER( pxIterator ) ); pxIterator = ( ListItem_t * ) listGET_NEXT( pxIterator ); /* Sockets with 'tmout == 0' do not need any regular attention. */ @@ -3142,7 +3163,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket ) { const ListItem_t *pxIterator; FreeRTOS_Socket_t *pxResult = NULL, *pxListenSocket = NULL; - const ListItem_t *pxEnd = ipPOINTER_CAST( const ListItem_t *, listGET_END_MARKER( &xBoundTCPSocketsList ) ); + const ListItem_t *pxEnd = listGET_END_MARKER( &xBoundTCPSocketsList ); /* Parameter not yet supported. */ ( void ) ulLocalIP; @@ -3151,7 +3172,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket ) pxIterator != pxEnd; pxIterator = listGET_NEXT( pxIterator ) ) { - FreeRTOS_Socket_t *pxSocket = ipPOINTER_CAST( FreeRTOS_Socket_t *, listGET_LIST_ITEM_OWNER( pxIterator ) ); + FreeRTOS_Socket_t *pxSocket = ipCAST_PTR_TO_TYPE_PTR( FreeRTOS_Socket_t, listGET_LIST_ITEM_OWNER( pxIterator ) ); if( pxSocket->usLocalPort == ( uint16_t ) uxLocalPort ) { @@ -3245,7 +3266,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket ) uxSize = ( sizeof( *pxBuffer ) + uxLength ) - sizeof( pxBuffer->ucArray ); - pxBuffer = ipPOINTER_CAST( StreamBuffer_t *, pvPortMallocLarge( uxSize ) ); + pxBuffer = ipCAST_PTR_TO_TYPE_PTR( StreamBuffer_t, pvPortMallocLarge( uxSize ) ); if( pxBuffer == NULL ) { @@ -3701,14 +3722,14 @@ BaseType_t FreeRTOS_udp_rx_size( Socket_t xSocket ) } else { - const ListItem_t *pxEndTCP = ipPOINTER_CAST( const ListItem_t *, listGET_END_MARKER( &xBoundTCPSocketsList ) ); - const ListItem_t *pxEndUDP = ipPOINTER_CAST( const ListItem_t *, listGET_END_MARKER( &xBoundUDPSocketsList ) ); + const ListItem_t *pxEndTCP = listGET_END_MARKER( &xBoundTCPSocketsList ); + const ListItem_t *pxEndUDP = listGET_END_MARKER( &xBoundUDPSocketsList ); FreeRTOS_printf( ( "Prot Port IP-Remote : Port R/T Status Alive tmout Child\n" ) ); for( pxIterator = listGET_HEAD_ENTRY( &xBoundTCPSocketsList ); pxIterator != pxEndTCP; pxIterator = listGET_NEXT( pxIterator ) ) { - const FreeRTOS_Socket_t *pxSocket = ipPOINTER_CAST( const FreeRTOS_Socket_t *, listGET_LIST_ITEM_OWNER( pxIterator ) ); + const FreeRTOS_Socket_t *pxSocket = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( FreeRTOS_Socket_t, listGET_LIST_ITEM_OWNER( pxIterator ) ); #if( ipconfigTCP_KEEP_ALIVE == 1 ) TickType_t age = xTaskGetTickCount() - pxSocket->u.xTCP.xLastAliveTime; #else @@ -3782,19 +3803,19 @@ BaseType_t FreeRTOS_udp_rx_size( Socket_t xSocket ) const ListItem_t *pxEnd; if( xRound == 0 ) { - pxEnd = ipPOINTER_CAST( const ListItem_t *, listGET_END_MARKER( &xBoundUDPSocketsList ) ); + pxEnd = listGET_END_MARKER( &xBoundUDPSocketsList ); } #if ipconfigUSE_TCP == 1 else { - pxEnd = ipPOINTER_CAST( const ListItem_t *, listGET_END_MARKER( &xBoundTCPSocketsList ) ); + pxEnd = listGET_END_MARKER( &xBoundTCPSocketsList ); } #endif /* ipconfigUSE_TCP == 1 */ for( pxIterator = listGET_NEXT( pxEnd ); pxIterator != pxEnd; pxIterator = listGET_NEXT( pxIterator ) ) { - FreeRTOS_Socket_t *pxSocket = ipPOINTER_CAST( FreeRTOS_Socket_t *, listGET_LIST_ITEM_OWNER( pxIterator ) ); + FreeRTOS_Socket_t *pxSocket = ipCAST_PTR_TO_TYPE_PTR( FreeRTOS_Socket_t, listGET_LIST_ITEM_OWNER( pxIterator ) ); if( pxSocket->pxSocketSet != pxSocketSet ) { /* Socket does not belong to this select group. */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_IP_Private.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_IP_Private.h index e9478d946..f25431222 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_IP_Private.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_IP_Private.h @@ -85,6 +85,17 @@ struct xETH_HEADER #include "pack_struct_end.h" typedef struct xETH_HEADER EthernetHeader_t; +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( EthernetHeader_t ) +{ + return ( EthernetHeader_t *)pvArgument; +} + +static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( EthernetHeader_t ) +{ + return ( const EthernetHeader_t *) pvArgument; +} + + #include "pack_struct_start.h" struct xARP_HEADER { @@ -130,6 +141,16 @@ struct xICMP_HEADER #include "pack_struct_end.h" typedef struct xICMP_HEADER ICMPHeader_t; +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( ICMPHeader_t ) +{ + return ( ICMPHeader_t *)pvArgument; +} +static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( ICMPHeader_t ) +{ + return ( const ICMPHeader_t *) pvArgument; +} + + #include "pack_struct_start.h" struct xUDP_HEADER { @@ -174,6 +195,16 @@ struct xARP_PACKET #include "pack_struct_end.h" typedef struct xARP_PACKET ARPPacket_t; +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( ARPPacket_t ) +{ + return ( ARPPacket_t *)pvArgument; +} +static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( ARPPacket_t ) +{ + return ( const ARPPacket_t *) pvArgument; +} + + #include "pack_struct_start.h" struct xIP_PACKET { @@ -183,6 +214,16 @@ struct xIP_PACKET #include "pack_struct_end.h" typedef struct xIP_PACKET IPPacket_t; +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( IPPacket_t ) +{ + return ( IPPacket_t *)pvArgument; +} +static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( IPPacket_t ) +{ + return ( const IPPacket_t *) pvArgument; +} + + #include "pack_struct_start.h" struct xICMP_PACKET { @@ -193,6 +234,12 @@ struct xICMP_PACKET #include "pack_struct_end.h" typedef struct xICMP_PACKET ICMPPacket_t; +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( ICMPPacket_t ) +{ + return ( ICMPPacket_t *)pvArgument; +} + + #include "pack_struct_start.h" struct xUDP_PACKET { @@ -205,12 +252,10 @@ typedef struct xUDP_PACKET UDPPacket_t; static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( UDPPacket_t ) { - /* coverity[misra_c_2012_rule_11_3_violation] */ return ( UDPPacket_t *)pvArgument; } static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( UDPPacket_t ) { - /* coverity[misra_c_2012_rule_11_3_violation] */ return ( const UDPPacket_t *) pvArgument; } @@ -232,6 +277,15 @@ typedef union XPROT_PACKET ICMPPacket_t xICMPPacket; } ProtocolPacket_t; +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( ProtocolPacket_t ) +{ + return ( ProtocolPacket_t *)pvArgument; +} +static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( ProtocolPacket_t ) +{ + return ( const ProtocolPacket_t *) pvArgument; +} + typedef union xPROT_HEADERS { ICMPHeader_t xICMPHeader; @@ -690,6 +744,15 @@ typedef struct xSOCKET } u; } FreeRTOS_Socket_t; +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( FreeRTOS_Socket_t ) +{ + return ( FreeRTOS_Socket_t *)pvArgument; +} +static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( FreeRTOS_Socket_t ) +{ + return ( const FreeRTOS_Socket_t *) pvArgument; +} + #if( ipconfigUSE_TCP == 1 ) /* * Lookup a TCP socket, using a multiple matching: both port numbers and @@ -826,6 +889,15 @@ typedef struct xSOCKET_SET EventGroupHandle_t xSelectGroup; } SocketSelect_t; +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( SocketSelect_t ) +{ + return ( SocketSelect_t *)pvArgument; +} +static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( SocketSelect_t ) +{ + return ( const SocketSelect_t *) pvArgument; +} + extern void vSocketSelect( SocketSelect_t *pxSocketSet ); /* Define the data that must be passed for a 'eSocketSelectEvent'. */ @@ -835,6 +907,15 @@ typedef struct xSocketSelectMessage SocketSelect_t *pxSocketSet; } SocketSelectMessage_t; +static portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( SocketSelectMessage_t ) +{ + return ( SocketSelectMessage_t *)pvArgument; +} +static portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( SocketSelectMessage_t ) +{ + return ( const SocketSelectMessage_t *) pvArgument; +} + #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ void vIPSetDHCPTimerEnableState( BaseType_t xEnableState ); |