Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions MISRA.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ with ( Assuming rule 11.4 violation; with justification in point 2 ):
grep 'MISRA Ref 11.4.2' . -rI
```

#### Directive 4.7

_Ref 4.7.1_

- MISRA C:2012 Directive 4.7: Return value shall be checked.
MISRA warns against not checking the return value of functions that
does return. However, the violations reported in FreeRTOS-Plus-TCP
library for this directive are for the cases where the validity of the
subsequent expressions are validated by ways other than return
value of the called function, for example pointer value
that was passed as argument.

#### Directive 4.12

_Ref 4.12.1_
Expand Down
2 changes: 1 addition & 1 deletion source/FreeRTOS_ARP.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@
}
}
}
else if( xIsIPv4Broadcast( ulAddressToLookup, ppxEndPoint ) )
else if( xIsIPv4Broadcast( ulAddressToLookup, ppxEndPoint ) == pdTRUE )
{
/* This is a broadcast so it uses the broadcast MAC address. */
( void ) memcpy( pxMACAddress->ucBytes, xBroadcastMACAddress.ucBytes, sizeof( MACAddress_t ) );
Expand Down
1 change: 1 addition & 0 deletions source/FreeRTOS_DHCP.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
}
else
{
/* do nothing, coverity happy */
}

break;
Expand Down
1 change: 1 addition & 0 deletions source/FreeRTOS_DHCPv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ void vDHCPv6Process( BaseType_t xReset,
}
else
{
/* do nothing, coverity happy */
}

break;
Expand Down
3 changes: 3 additions & 0 deletions source/FreeRTOS_IP_Utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,9 @@ void vReleaseSinglePacketFromUDPSocket( const ConstSocket_t xSocket )
int32_t lBytes;

/* Passing the address of a pointer (pucUDPPayload) because FREERTOS_ZERO_COPY is used. */
/* MISRA Ref 4.7.1 [Return value shall be checked] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#directive-47. */
/* coverity[misra_c_2012_directive_4_7_violation] */
lBytes = FreeRTOS_recvfrom( xSocket, &pucUDPPayload, 0U, FREERTOS_ZERO_COPY, NULL, NULL );

( void ) lBytes;
Expand Down
8 changes: 6 additions & 2 deletions source/FreeRTOS_IPv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,18 @@ BaseType_t xIsIPv4Broadcast( uint32_t ulIPAddress,
xIsBroadcast = pdTRUE;
break;
}
else
{
/* do nothing, coverity happy */
}
}

/* If the caller wants to know the corresponding endpoint, copy the result.
* Note that this may be null if ulIPAddress is 255.255.255.255 AND there are
* no IPv4 endpoints.
* Also, when ulIPAddress is 255.255.255.255, we will
* return the first IPv4 endpoint that we run across. */
if( xIsBroadcast && ( ppxEndPoint != NULL ) )
if( ( xIsBroadcast == pdTRUE ) && ( ppxEndPoint != NULL ) )
{
*ppxEndPoint = pxEndPoint;
}
Expand Down Expand Up @@ -347,7 +351,7 @@ enum eFrameProcessingResult prvAllowIPPacketIPv4( const struct xIP_PACKET * cons
uint32_t ulDestinationIPAddress = pxIPHeader->ulDestinationIPAddress;
uint32_t ulSourceIPAddress = pxIPHeader->ulSourceIPAddress;
/* Get a reference to the endpoint that the packet was assigned to during pxEasyFit() */
NetworkEndPoint_t * pxEndPoint = pxNetworkBuffer->pxEndPoint;
const NetworkEndPoint_t * pxEndPoint = pxNetworkBuffer->pxEndPoint;

/* Ensure that the incoming packet is not fragmented because the stack
* doesn't not support IP fragmentation. All but the last fragment coming in will have their
Expand Down
3 changes: 3 additions & 0 deletions source/FreeRTOS_TCP_Transmission.c
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,9 @@
uint32_t ulCurrentSequenceNumber,
uint32_t ulOurSequenceNumber )
{
/* 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] */
ProtocolHeaders_t * pxProtocolHeaders = ( ( ProtocolHeaders_t * )
&( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + uxIPHeaderSizePacket( pxNetworkBuffer ) ] ) );

Expand Down