Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab3b51c

Browse files
AniruddhaKanhereyuhui-zheng
authored andcommitted
Update after Gary's comments
1 parent 97f7009 commit ab3b51c

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ uint32_t ulTargetProtocolAddress, ulSenderProtocolAddress;
118118
pxARPHeader = &( pxARPFrame->xARPHeader );
119119

120120
/* The field ulSenderProtocolAddress is badly aligned, copy byte-by-byte. */
121-
( void ) memcpy( ( void * )&( ulSenderProtocolAddress ), ( void * )pxARPHeader->ucSenderProtocolAddress, sizeof( ulSenderProtocolAddress ) );
121+
( void ) memcpy( ( void * )&( ulSenderProtocolAddress ), ( const void * )pxARPHeader->ucSenderProtocolAddress, sizeof( ulSenderProtocolAddress ) );
122122
/* The field ulTargetProtocolAddress is well-aligned, a 32-bits copy. */
123123
ulTargetProtocolAddress = pxARPHeader->ulTargetProtocolAddress;
124124

@@ -191,7 +191,7 @@ uint32_t ulTargetProtocolAddress, ulSenderProtocolAddress;
191191

192192
#if( ipconfigUSE_ARP_REMOVE_ENTRY != 0 )
193193

194-
uint32_t ulARPRemoveCacheEntryByMac(const MACAddress_t* pxMACAddress)
194+
uint32_t ulARPRemoveCacheEntryByMac( const MACAddress_t * pxMACAddress )
195195
{
196196
BaseType_t x;
197197
uint32_t lResult = 0;
@@ -264,12 +264,7 @@ uint8_t ucMinAgeFound = 0U;
264264
is relaxed in this case and a return is permitted as an
265265
optimisation. */
266266
xARPCache[ x ].ucAge = ( uint8_t ) ipconfigMAX_ARP_AGE;
267-
xARPCache[ x ].ucValid = ( uint8_t ) pdTRUE;
268-
269-
/* MISRA rule 15.5 relaxed for reduced complexity. Not putting
270-
* a return here will increase cyclomatic complexity in later
271-
* part of the code */
272-
/* coverity[misra_c_2012_rule_15_5_violation] */
267+
xARPCache[ x ].ucValid = ( uint8_t ) pdTRUE;
273268
return;
274269
}
275270

@@ -311,7 +306,7 @@ uint8_t ucMinAgeFound = 0U;
311306
ucMinAgeFound = xARPCache[ x ].ucAge;
312307
xUseEntry = x;
313308
}
314-
else /* Added to suppress MISRA rule 15.7 violation */
309+
else
315310
{
316311
/* Do nothing. */
317312
}
@@ -358,7 +353,7 @@ uint8_t ucMinAgeFound = 0U;
358353
}
359354
else
360355
{
361-
/* Do nothing. (pxMACAddress = NULL) and (xIPEntry > 0)
356+
/* Do nothing. (pxMACAddress == NULL) and (xIPEntry > 0)
362357
* Implies that an IP address was found but we don't have
363358
* a MAC address for it. Therefore, no action required */
364359
}
@@ -377,7 +372,7 @@ uint8_t ucMinAgeFound = 0U;
377372
{
378373
/* Does this row in the ARP cache table hold an entry for the MAC
379374
address being searched? */
380-
if( ( void ) memcmp( pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 )
375+
if( memcmp( pxMACAddress->ucBytes, xARPCache[ x ].xMACAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 )
381376
{
382377
*pulIPAddress = xARPCache[ x ].ulIPAddress;
383378
eReturn = eARPCacheHit;
@@ -652,12 +647,9 @@ ARPPacket_t *pxARPPacket;
652647
xARPHeader.xTargetHardwareAddress;
653648
*/
654649

655-
/* Also, for rule 21.15 regarding using same pointer-to-x types for memcpy,
656-
* below is done intentionally here and thus the rule is relaxed */
657-
/* coverity[misra_c_2012_rule_21_15_violation] */
658-
( void ) memcpy( ( void * ) pxARPPacket, ( const void* )xDefaultPartARPPacketHeader, sizeof( xDefaultPartARPPacketHeader ) );
659-
( void ) memcpy( ( void * ) pxARPPacket->xEthernetHeader.xSourceAddress.ucBytes, ( void * ) ipLOCAL_MAC_ADDRESS, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES );
660-
( void ) memcpy( ( void * ) pxARPPacket->xARPHeader.xSenderHardwareAddress.ucBytes, ( void * )ipLOCAL_MAC_ADDRESS, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES );
650+
( void ) memcpy( ( void * ) pxARPPacket, ( const void * )xDefaultPartARPPacketHeader, sizeof( xDefaultPartARPPacketHeader ) );
651+
( void ) memcpy( ( void * ) pxARPPacket->xEthernetHeader.xSourceAddress.ucBytes, ( const void * ) ipLOCAL_MAC_ADDRESS, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES );
652+
( void ) memcpy( ( void * ) pxARPPacket->xARPHeader.xSenderHardwareAddress.ucBytes, ( const void * )ipLOCAL_MAC_ADDRESS, ( size_t )ipMAC_ADDRESS_LENGTH_BYTES );
661653

662654
( void ) memcpy( ( void * )pxARPPacket->xARPHeader.ucSenderProtocolAddress, ( void * )ipLOCAL_IP_ADDRESS_POINTER, sizeof( pxARPPacket->xARPHeader.ucSenderProtocolAddress ) );
663655
pxARPPacket->xARPHeader.ulTargetProtocolAddress = pxNetworkBuffer->ulIPAddress;

0 commit comments

Comments
 (0)