Update after richard's comments

This commit is contained in:
AniruddhaKanhere 2020-04-08 14:30:15 -07:00 committed by Yuhui Zheng
parent a9fcafc074
commit 97f7009699

View file

@ -118,7 +118,7 @@ uint32_t ulTargetProtocolAddress, ulSenderProtocolAddress;
pxARPHeader = &( pxARPFrame->xARPHeader ); pxARPHeader = &( pxARPFrame->xARPHeader );
/* The field ulSenderProtocolAddress is badly aligned, copy byte-by-byte. */ /* The field ulSenderProtocolAddress is badly aligned, copy byte-by-byte. */
memcpy( ( void * )&( ulSenderProtocolAddress ), ( void * )pxARPHeader->ucSenderProtocolAddress, sizeof( ulSenderProtocolAddress ) ); ( void ) memcpy( ( void * )&( ulSenderProtocolAddress ), ( void * )pxARPHeader->ucSenderProtocolAddress, sizeof( ulSenderProtocolAddress ) );
/* The field ulTargetProtocolAddress is well-aligned, a 32-bits copy. */ /* The field ulTargetProtocolAddress is well-aligned, a 32-bits copy. */
ulTargetProtocolAddress = pxARPHeader->ulTargetProtocolAddress; ulTargetProtocolAddress = pxARPHeader->ulTargetProtocolAddress;
@ -148,17 +148,17 @@ uint32_t ulTargetProtocolAddress, ulSenderProtocolAddress;
{ {
/* A double IP address is detected! */ /* A double IP address is detected! */
/* Give the sources MAC address the value of the broadcast address, will be swapped later */ /* Give the sources MAC address the value of the broadcast address, will be swapped later */
memcpy( pxARPFrame->xEthernetHeader.xSourceAddress.ucBytes, xBroadcastMACAddress.ucBytes, sizeof( xBroadcastMACAddress ) ); ( void ) memcpy( pxARPFrame->xEthernetHeader.xSourceAddress.ucBytes, xBroadcastMACAddress.ucBytes, sizeof( xBroadcastMACAddress ) );
memset( pxARPHeader->xTargetHardwareAddress.ucBytes, 0, sizeof( MACAddress_t ) ); ( void ) memset( pxARPHeader->xTargetHardwareAddress.ucBytes, 0, sizeof( MACAddress_t ) );
pxARPHeader->ulTargetProtocolAddress = 0UL; pxARPHeader->ulTargetProtocolAddress = 0UL;
} }
else else
{ {
memcpy( pxARPHeader->xTargetHardwareAddress.ucBytes, pxARPHeader->xSenderHardwareAddress.ucBytes, sizeof( MACAddress_t ) ); ( void ) memcpy( pxARPHeader->xTargetHardwareAddress.ucBytes, pxARPHeader->xSenderHardwareAddress.ucBytes, sizeof( MACAddress_t ) );
pxARPHeader->ulTargetProtocolAddress = ulSenderProtocolAddress; pxARPHeader->ulTargetProtocolAddress = ulSenderProtocolAddress;
} }
memcpy( pxARPHeader->xSenderHardwareAddress.ucBytes, ( void * )ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); ( void ) memcpy( pxARPHeader->xSenderHardwareAddress.ucBytes, ( void * ) ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) );
memcpy( ( void * )pxARPHeader->ucSenderProtocolAddress, ( void * )ipLOCAL_IP_ADDRESS_POINTER, sizeof( pxARPHeader->ucSenderProtocolAddress ) ); ( void ) memcpy( ( void * ) pxARPHeader->ucSenderProtocolAddress, ( void * ) ipLOCAL_IP_ADDRESS_POINTER, sizeof( pxARPHeader->ucSenderProtocolAddress ) );
eReturn = eReturnEthernetFrame; eReturn = eReturnEthernetFrame;
} }
@ -173,7 +173,7 @@ uint32_t ulTargetProtocolAddress, ulSenderProtocolAddress;
if( ulSenderProtocolAddress == *ipLOCAL_IP_ADDRESS_POINTER ) if( ulSenderProtocolAddress == *ipLOCAL_IP_ADDRESS_POINTER )
{ {
xARPHadIPClash = pdTRUE; xARPHadIPClash = pdTRUE;
memcpy( xARPClashMacAddress.ucBytes, pxARPHeader->xSenderHardwareAddress.ucBytes, sizeof( xARPClashMacAddress.ucBytes ) ); ( void ) memcpy( xARPClashMacAddress.ucBytes, pxARPHeader->xSenderHardwareAddress.ucBytes, sizeof( xARPClashMacAddress.ucBytes ) );
} }
} }
#endif /* ipconfigARP_USE_CLASH_DETECTION */ #endif /* ipconfigARP_USE_CLASH_DETECTION */
@ -202,7 +202,7 @@ uint32_t ulTargetProtocolAddress, ulSenderProtocolAddress;
if( ( memcmp( xARPCache[ x ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ) == 0 ) ) if( ( memcmp( xARPCache[ x ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ) == 0 ) )
{ {
lResult = xARPCache[ x ].ulIPAddress; lResult = xARPCache[ x ].ulIPAddress;
memset(&xARPCache[x], '\0', sizeof(xARPCache[x])); ( void ) memset( &xARPCache[ x ], '\0', sizeof( xARPCache[ x ] ) );
break; break;
} }
} }
@ -226,7 +226,7 @@ uint8_t ucMinAgeFound = 0U;
Unless: when '*ipLOCAL_IP_ADDRESS_POINTER' equals zero, the IP-address Unless: when '*ipLOCAL_IP_ADDRESS_POINTER' equals zero, the IP-address
and netmask are still unknown. */ and netmask are still unknown. */
if( ( ( ulIPAddress & xNetworkAddressing.ulNetMask ) == ( ( *ipLOCAL_IP_ADDRESS_POINTER ) & xNetworkAddressing.ulNetMask ) ) || if( ( ( ulIPAddress & xNetworkAddressing.ulNetMask ) == ( ( *ipLOCAL_IP_ADDRESS_POINTER ) & xNetworkAddressing.ulNetMask ) ) ||
( *ipLOCAL_IP_ADDRESS_POINTER == 0UL ) ) ( *ipLOCAL_IP_ADDRESS_POINTER == 0uL ) )
#else #else
/* If ipconfigARP_STORES_REMOTE_ADDRESSES is non-zero, IP addresses with /* If ipconfigARP_STORES_REMOTE_ADDRESSES is non-zero, IP addresses with
a different netmask will also be stored. After when replying to a UDP a different netmask will also be stored. After when replying to a UDP
@ -326,7 +326,7 @@ uint8_t ucMinAgeFound = 0U;
/* Both the MAC address as well as the IP address were found in /* Both the MAC address as well as the IP address were found in
different locations: clear the entry which matches the different locations: clear the entry which matches the
IP-address */ IP-address */
memset( &xARPCache[ xIpEntry ], 0, sizeof( xARPCache[ xIpEntry ] ) ); ( void ) memset( &xARPCache[ xIpEntry ], 0, sizeof( xARPCache[ xIpEntry ] ) );
} }
} }
else if( xIpEntry >= 0 ) else if( xIpEntry >= 0 )
@ -344,7 +344,7 @@ uint8_t ucMinAgeFound = 0U;
if( pxMACAddress != NULL ) if( pxMACAddress != NULL )
{ {
memcpy( xARPCache[ xUseEntry ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) ); ( void ) memcpy( xARPCache[ xUseEntry ].xMACAddress.ucBytes, pxMACAddress->ucBytes, sizeof( pxMACAddress->ucBytes ) );
iptraceARP_TABLE_ENTRY_CREATED( ulIPAddress, ( *pxMACAddress ) ); iptraceARP_TABLE_ENTRY_CREATED( ulIPAddress, ( *pxMACAddress ) );
/* And this entry does not need immediate attention */ /* And this entry does not need immediate attention */
@ -377,7 +377,7 @@ uint8_t ucMinAgeFound = 0U;
{ {
/* Does this row in the ARP cache table hold an entry for the MAC /* Does this row in the ARP cache table hold an entry for the MAC
address being searched? */ address being searched? */
if ( memcmp(pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) if( ( void ) memcmp( pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 )
{ {
*pulIPAddress = xARPCache[ x ].ulIPAddress; *pulIPAddress = xARPCache[ x ].ulIPAddress;
eReturn = eARPCacheHit; eReturn = eARPCacheHit;
@ -400,7 +400,7 @@ uint32_t ulAddressToLookup;
if( *pulIPAddress == ipLLMNR_IP_ADDR ) /* Is in network byte order. */ if( *pulIPAddress == ipLLMNR_IP_ADDR ) /* Is in network byte order. */
{ {
/* The LLMNR IP-address has a fixed virtual MAC address. */ /* The LLMNR IP-address has a fixed virtual MAC address. */
memcpy( pxMACAddress->ucBytes, xLLMNR_MacAdress.ucBytes, sizeof( MACAddress_t ) ); ( void ) memcpy( pxMACAddress->ucBytes, xLLMNR_MacAdress.ucBytes, sizeof( MACAddress_t ) );
eReturn = eARPCacheHit; eReturn = eARPCacheHit;
} }
else else
@ -409,7 +409,7 @@ uint32_t ulAddressToLookup;
( *pulIPAddress == xNetworkAddressing.ulBroadcastAddress ) )/* Or a local broadcast address, eg 192.168.1.255? */ ( *pulIPAddress == xNetworkAddressing.ulBroadcastAddress ) )/* Or a local broadcast address, eg 192.168.1.255? */
{ {
/* This is a broadcast so uses the broadcast MAC address. */ /* This is a broadcast so uses the broadcast MAC address. */
memcpy( pxMACAddress->ucBytes, xBroadcastMACAddress.ucBytes, sizeof( MACAddress_t ) ); ( void ) memcpy( pxMACAddress->ucBytes, xBroadcastMACAddress.ucBytes, sizeof( MACAddress_t ) );
eReturn = eARPCacheHit; eReturn = eARPCacheHit;
} }
else if( *ipLOCAL_IP_ADDRESS_POINTER == 0UL ) else if( *ipLOCAL_IP_ADDRESS_POINTER == 0UL )
@ -502,7 +502,7 @@ eARPLookupResult_t eReturn = eARPCacheMiss;
else else
{ {
/* A valid entry was found. */ /* A valid entry was found. */
memcpy( pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ); ( void ) memcpy( pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) );
eReturn = eARPCacheHit; eReturn = eARPCacheHit;
} }
break; break;
@ -655,11 +655,11 @@ ARPPacket_t* pxARPPacket;
/* Also, for rule 21.15 regarding using same pointer-to-x types for memcpy, /* Also, for rule 21.15 regarding using same pointer-to-x types for memcpy,
* below is done intentionally here and thus the rule is relaxed */ * below is done intentionally here and thus the rule is relaxed */
/* coverity[misra_c_2012_rule_21_15_violation] */ /* coverity[misra_c_2012_rule_21_15_violation] */
memcpy( ( void * ) pxARPPacket, ( const void* )xDefaultPartARPPacketHeader, sizeof( xDefaultPartARPPacketHeader ) ); ( void ) memcpy( ( void * ) pxARPPacket, ( const void* )xDefaultPartARPPacketHeader, sizeof( xDefaultPartARPPacketHeader ) );
memcpy( ( void * ) pxARPPacket->xEthernetHeader.xSourceAddress.ucBytes, ( void * ) ipLOCAL_MAC_ADDRESS, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES ); ( void ) memcpy( ( void * ) pxARPPacket->xEthernetHeader.xSourceAddress.ucBytes, ( void * ) ipLOCAL_MAC_ADDRESS, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES );
memcpy( ( void * ) pxARPPacket->xARPHeader.xSenderHardwareAddress.ucBytes, ( void * )ipLOCAL_MAC_ADDRESS, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES ); ( void ) memcpy( ( void * ) pxARPPacket->xARPHeader.xSenderHardwareAddress.ucBytes, ( void * )ipLOCAL_MAC_ADDRESS, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES );
memcpy( ( void * )pxARPPacket->xARPHeader.ucSenderProtocolAddress, ( void * )ipLOCAL_IP_ADDRESS_POINTER, sizeof( pxARPPacket->xARPHeader.ucSenderProtocolAddress ) ); ( void ) memcpy( ( void * )pxARPPacket->xARPHeader.ucSenderProtocolAddress, ( void * )ipLOCAL_IP_ADDRESS_POINTER, sizeof( pxARPPacket->xARPHeader.ucSenderProtocolAddress ) );
pxARPPacket->xARPHeader.ulTargetProtocolAddress = pxNetworkBuffer->ulIPAddress; pxARPPacket->xARPHeader.ulTargetProtocolAddress = pxNetworkBuffer->ulIPAddress;
pxNetworkBuffer->xDataLength = sizeof( ARPPacket_t ); pxNetworkBuffer->xDataLength = sizeof( ARPPacket_t );
@ -670,7 +670,7 @@ ARPPacket_t* pxARPPacket;
void FreeRTOS_ClearARP( void ) void FreeRTOS_ClearARP( void )
{ {
memset( xARPCache, 0, sizeof( xARPCache ) ); ( void ) memset( xARPCache, 0, sizeof( xARPCache ) );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/