Skip to content

Commit 9402542

Browse files
Merge branch 'main' into stm32-networkinterface-bugfixes
2 parents 4e3ba1b + 07b203f commit 9402542

File tree

8 files changed

+65
-20
lines changed

8 files changed

+65
-20
lines changed

MISRA.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ with ( Assuming rule 11.4 violation; with justification in point 2 ):
2222
grep 'MISRA Ref 11.4.2' . -rI
2323
```
2424

25+
#### Directive 4.7
26+
27+
_Ref 4.7.1_
28+
29+
- MISRA C:2012 Directive 4.7: Return value shall be checked.
30+
MISRA warns against not checking the return value of functions that
31+
does return. However, the violations reported in FreeRTOS-Plus-TCP
32+
library for this directive are for the cases where the validity of the
33+
subsequent expressions are validated by ways other than return
34+
value of the called function, for example pointer value
35+
that was passed as argument.
36+
2537
#### Directive 4.12
2638

2739
_Ref 4.12.1_

source/FreeRTOS_ARP.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@
926926
}
927927
}
928928
}
929-
else if( xIsIPv4Broadcast( ulAddressToLookup, ppxEndPoint ) )
929+
else if( xIsIPv4Broadcast( ulAddressToLookup, ppxEndPoint ) == pdTRUE )
930930
{
931931
/* This is a broadcast so it uses the broadcast MAC address. */
932932
( void ) memcpy( pxMACAddress->ucBytes, xBroadcastMACAddress.ucBytes, sizeof( MACAddress_t ) );

source/FreeRTOS_DHCP.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
}
231231
else
232232
{
233+
/* do nothing, coverity happy */
233234
}
234235

235236
break;

source/FreeRTOS_DHCPv6.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ void vDHCPv6Process( BaseType_t xReset,
442442
}
443443
else
444444
{
445+
/* do nothing, coverity happy */
445446
}
446447

447448
break;

source/FreeRTOS_IP_Utils.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,26 +1004,29 @@ void vPreCheckConfigs( void )
10041004
{
10051005
size_t uxSize;
10061006

1007-
/* Check if ipBUFFER_PADDING has a minimum size, depending on the platform.
1008-
* See FreeRTOS_IP.h for more details. */
1009-
#if ( UINTPTR_MAX > 0xFFFFFFFFU )
1007+
#if ( ipconfigSUPPRESS_BUFFER_PADDING_CHECK == 0 )
1008+
1009+
/* Check if ipBUFFER_PADDING has a minimum size, depending on the platform.
1010+
* See FreeRTOS_IP.h for more details. */
1011+
#if ( UINTPTR_MAX > 0xFFFFFFFFU )
1012+
1013+
/*
1014+
* This is a 64-bit platform, make sure there is enough space in
1015+
* pucEthernetBuffer to store a pointer.
1016+
*/
1017+
configASSERT( ipBUFFER_PADDING >= 14U );
1018+
#else
1019+
/* This is a 32-bit platform. */
1020+
configASSERT( ipBUFFER_PADDING >= 10U );
1021+
#endif /* UINTPTR_MAX > 0xFFFFFFFFU */
10101022

10111023
/*
1012-
* This is a 64-bit platform, make sure there is enough space in
1013-
* pucEthernetBuffer to store a pointer.
1024+
* The size of the Ethernet header (14) plus ipBUFFER_PADDING should be a
1025+
* multiple of 32 bits, in order to get aligned access to all uint32_t
1026+
* fields in the protocol headers.
10141027
*/
1015-
configASSERT( ipBUFFER_PADDING >= 14U );
1016-
#else
1017-
/* This is a 32-bit platform. */
1018-
configASSERT( ipBUFFER_PADDING >= 10U );
1019-
#endif /* UINTPTR_MAX > 0xFFFFFFFFU */
1020-
1021-
/*
1022-
* The size of the Ethernet header (14) plus ipBUFFER_PADDING should be a
1023-
* multiple of 32 bits, in order to get aligned access to all uint32_t
1024-
* fields in the protocol headers.
1025-
*/
1026-
configASSERT( ( ( ( ipSIZE_OF_ETH_HEADER ) + ( ipBUFFER_PADDING ) ) % 4U ) == 0U );
1028+
configASSERT( ( ( ( ipSIZE_OF_ETH_HEADER ) + ( ipBUFFER_PADDING ) ) % 4U ) == 0U );
1029+
#endif /* if ( ipconfigSUPPRESS_BUFFER_PADDING_CHECK == 0 ) */
10271030

10281031
/* LCOV_EXCL_BR_START */
10291032
uxSize = ipconfigNETWORK_MTU;
@@ -1835,6 +1838,9 @@ void vReleaseSinglePacketFromUDPSocket( const ConstSocket_t xSocket )
18351838
int32_t lBytes;
18361839

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

18401846
( void ) lBytes;

source/FreeRTOS_IPv4.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,18 @@ BaseType_t xIsIPv4Broadcast( uint32_t ulIPAddress,
253253
xIsBroadcast = pdTRUE;
254254
break;
255255
}
256+
else
257+
{
258+
/* do nothing, coverity happy */
259+
}
256260
}
257261

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

352356
/* Ensure that the incoming packet is not fragmented because the stack
353357
* doesn't not support IP fragmentation. All but the last fragment coming in will have their

source/FreeRTOS_TCP_Transmission.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,9 @@
13611361
uint32_t ulCurrentSequenceNumber,
13621362
uint32_t ulOurSequenceNumber )
13631363
{
1364+
/* MISRA Ref 11.3.1 [Misaligned access] */
1365+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
1366+
/* coverity[misra_c_2012_rule_11_3_violation] */
13641367
ProtocolHeaders_t * pxProtocolHeaders = ( ( ProtocolHeaders_t * )
13651368
&( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + uxIPHeaderSizePacket( pxNetworkBuffer ) ] ) );
13661369

source/include/FreeRTOSIPConfigDefaults.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3403,6 +3403,24 @@ STATIC_ASSERT( ipconfigDNS_SEND_BLOCK_TIME_TICKS <= portMAX_DELAY );
34033403

34043404
/*---------------------------------------------------------------------------*/
34053405

3406+
/*
3407+
* ipconfigSUPPRESS_BUFFER_PADDING_CHECK
3408+
*
3409+
* Type: BaseType_t ( ipconfigENABLE | ipconfigDISABLE )
3410+
*
3411+
* Suppress configuration check when user configuration
3412+
* for ipconfigPACKET_FILLER_SIZE or ipconfigBUFFER_PADDING is
3413+
* sub optimal. Useful when porting to a MAC that does not include
3414+
* the option to pad received packets ipconfigPACKET_FILLER_SIZE
3415+
* within a word boundary.
3416+
*/
3417+
3418+
#ifndef ipconfigSUPPRESS_BUFFER_PADDING_CHECK
3419+
#define ipconfigSUPPRESS_BUFFER_PADDING_CHECK ipconfigDISABLE
3420+
#endif
3421+
3422+
/*---------------------------------------------------------------------------*/
3423+
34063424
/*
34073425
* ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS
34083426
*

0 commit comments

Comments
 (0)