mirror of
https://github.com/FreeRTOS/FreeRTOS-Plus-TCP
synced 2025-10-24 20:29:40 +08:00
Misra fix or suppress remaining violations (#529)
* Fix Remaning misra issues * Suppress rule 8.6 * Fix/Suppress more misra violations * Style: for formatting * Style: fix formatting * Style: fix spelling * Fix Rule 11.1 * Fix undeteced suppressions * Enable 32 bits * Fix more misra leftover violations * Add justification for a missed violation * Fix comment for rule 8.13 * Fix comment * fix misra comments * Update MISRA.md Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> * Update source/FreeRTOS_Sockets.c Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> * Update source/portable/BufferManagement/BufferAllocation_2.c Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> * Update MISRA.md Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> * Update MISRA.md Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> * Suppress Rule 8.9 * Fix build error * fix build error * Fix coverity supression bugs Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>
This commit is contained in:
61
MISRA.md
61
MISRA.md
@@ -31,6 +31,35 @@ _Ref 8.9.1_
|
|||||||
order of execution, some variables have file scope definitions rather
|
order of execution, some variables have file scope definitions rather
|
||||||
than function scope.
|
than function scope.
|
||||||
|
|
||||||
|
#### Rule 8.13
|
||||||
|
_Ref 8.13.1_
|
||||||
|
|
||||||
|
- MISRA C-2012 Rule 8.13 Parameter passed is never used, should be declared as
|
||||||
|
const. The argument passed to the `prvIPTask` function is left unused which is
|
||||||
|
considered as the variable not being used and thus warranting the use of `const`.
|
||||||
|
However, the FreeRTOS-kernel function `xTaskCreate` expects a function signature
|
||||||
|
of type `void vSomeFunction( void * pvArgs )`. To satisfy that requirement, the
|
||||||
|
function signature of `prvIPTask` does not have a `const` qualifier in the
|
||||||
|
parameter signature.
|
||||||
|
|
||||||
|
#### Rule 10.5
|
||||||
|
_Ref 10.5.1_
|
||||||
|
|
||||||
|
- MISRA C-2012 Rule 10.5 Converting from an unsigned to an enum type. The
|
||||||
|
operation is safe to perform in that case, as we are using a generic API
|
||||||
|
to send and receive data, in that case the exact data sent it is received
|
||||||
|
|
||||||
|
#### Rule 11.1
|
||||||
|
_Ref 11.1.1_
|
||||||
|
|
||||||
|
- MISRA C-2012 Rule 11.1 Converting from a void pointer to a function pointer.
|
||||||
|
The `FreeRTOS_setsockopt` API allows users to configure sockets by setting
|
||||||
|
various options. In order to do so, the function must accept one parameter
|
||||||
|
which, based on the option value, can be casted to the corresponding socket
|
||||||
|
field. To that end, that parameter is of `void *` type to accommodate all values.
|
||||||
|
The caller of the API is responsible for providing correct function pointer to the
|
||||||
|
API. Thus, this violation can be safely suppressed.
|
||||||
|
|
||||||
#### Rule 11.3
|
#### Rule 11.3
|
||||||
_Ref 11.3.1_
|
_Ref 11.3.1_
|
||||||
|
|
||||||
@@ -107,16 +136,6 @@ _Ref 14.3.1_
|
|||||||
- MISRA C-2012 Rule 14.3 False positive as the value might be changed
|
- MISRA C-2012 Rule 14.3 False positive as the value might be changed
|
||||||
depending on the conditionally compiled code
|
depending on the conditionally compiled code
|
||||||
|
|
||||||
#### Rule 21.6
|
|
||||||
_Ref 21.6.1_
|
|
||||||
|
|
||||||
- MISRA C-2012 Rule 21.6 warns about the use of standard library input/output
|
|
||||||
functions as they might have implementation defined or undefined
|
|
||||||
behaviour. The function `snprintf` is used to insert information in a
|
|
||||||
logging string. This is only used in a utility function which aids in
|
|
||||||
debugging and is not part of the 'core' code governing the
|
|
||||||
functionality of the TCP/IP stack.
|
|
||||||
|
|
||||||
#### Rule 17.2
|
#### Rule 17.2
|
||||||
_Ref 17.2.1_
|
_Ref 17.2.1_
|
||||||
|
|
||||||
@@ -128,6 +147,17 @@ _Ref 17.2.1_
|
|||||||
have a secondary child socket thereby limiting the number of recursive
|
have a secondary child socket thereby limiting the number of recursive
|
||||||
calls to one.
|
calls to one.
|
||||||
|
|
||||||
|
#### Rule 20.5
|
||||||
|
_Ref 20.5.1_
|
||||||
|
|
||||||
|
- MISRA C-2012 Rule 20.5 warns against the use of #undef.
|
||||||
|
FreeRTOS-Plus-TCP allows its users to set some configuration macros
|
||||||
|
to modify the behavior/performance of the library according to their
|
||||||
|
needs. However, the macros values must be within certain bounds.
|
||||||
|
To achieve that, if the macro values lie outside of the bounds, they
|
||||||
|
are undefined using `#undef` before being redefined to a proper
|
||||||
|
value.
|
||||||
|
|
||||||
#### Rule 20.10
|
#### Rule 20.10
|
||||||
_Ref 20.10.1_
|
_Ref 20.10.1_
|
||||||
|
|
||||||
@@ -135,3 +165,14 @@ _Ref 20.10.1_
|
|||||||
However, in this case, it must be used to support compile time
|
However, in this case, it must be used to support compile time
|
||||||
assertions in case the preprocessor does not suppport sizeof. This
|
assertions in case the preprocessor does not suppport sizeof. This
|
||||||
operation (assert) has no runtime execution.
|
operation (assert) has no runtime execution.
|
||||||
|
|
||||||
|
#### Rule 21.6
|
||||||
|
_Ref 21.6.1_
|
||||||
|
|
||||||
|
- MISRA C-2012 Rule 21.6 warns about the use of standard library input/output
|
||||||
|
functions as they might have implementation defined or undefined
|
||||||
|
behaviour. The function `snprintf` is used to insert information in a
|
||||||
|
logging string. This is only used in a utility function which aids in
|
||||||
|
debugging and is not part of the 'core' code governing the
|
||||||
|
functionality of the TCP/IP stack.
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ static void prvProcessIPEventsAndTimers( void );
|
|||||||
* from the network hardware drivers and tasks that are using sockets. It also
|
* from the network hardware drivers and tasks that are using sockets. It also
|
||||||
* maintains a set of protocol timers.
|
* maintains a set of protocol timers.
|
||||||
*/
|
*/
|
||||||
static void prvIPTask( const void * pvParameters );
|
static void prvIPTask( void * pvParameters );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called when new data is available from the network interface.
|
* Called when new data is available from the network interface.
|
||||||
@@ -229,7 +229,11 @@ static BaseType_t xIPTaskInitialised = pdFALSE;
|
|||||||
*
|
*
|
||||||
* @param[in] pvParameters: Not used.
|
* @param[in] pvParameters: Not used.
|
||||||
*/
|
*/
|
||||||
static void prvIPTask( const void * pvParameters )
|
|
||||||
|
/* MISRA Ref 8.13.1 [Not decorating a pointer to const parameter with const] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-813 */
|
||||||
|
/* coverity[misra_c_2012_rule_8_13_violation] */
|
||||||
|
static void prvIPTask( void * pvParameters )
|
||||||
{
|
{
|
||||||
/* Just to prevent compiler warnings about unused parameters. */
|
/* Just to prevent compiler warnings about unused parameters. */
|
||||||
( void ) pvParameters;
|
( void ) pvParameters;
|
||||||
@@ -390,9 +394,11 @@ static void prvProcessIPEventsAndTimers( void )
|
|||||||
eDHCPState_t eState;
|
eDHCPState_t eState;
|
||||||
|
|
||||||
/* MISRA Ref 11.6.1 [DHCP events and conversion to void] */
|
/* MISRA Ref 11.6.1 [DHCP events and conversion to void] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-116 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-116 */
|
||||||
/* coverity[misra_c_2012_rule_11_6_violation] */
|
/* coverity[misra_c_2012_rule_11_6_violation] */
|
||||||
uxState = ( uintptr_t ) xReceivedEvent.pvData;
|
uxState = ( uintptr_t ) xReceivedEvent.pvData;
|
||||||
|
/* MISRA Ref 10.5.1 [DHCP events Enum] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-105 */
|
||||||
/* coverity[misra_c_2012_rule_10_5_violation] */
|
/* coverity[misra_c_2012_rule_10_5_violation] */
|
||||||
eState = ( eDHCPState_t ) uxState;
|
eState = ( eDHCPState_t ) uxState;
|
||||||
|
|
||||||
@@ -708,6 +714,7 @@ void * FreeRTOS_GetUDPPayloadBuffer( size_t uxRequestedSizeBytes,
|
|||||||
* @return pdPASS if the task was successfully created and added to a ready
|
* @return pdPASS if the task was successfully created and added to a ready
|
||||||
* list, otherwise an error code defined in the file projdefs.h
|
* list, otherwise an error code defined in the file projdefs.h
|
||||||
*/
|
*/
|
||||||
|
/* coverity[single_use] */
|
||||||
BaseType_t FreeRTOS_IPInit( const uint8_t ucIPAddress[ ipIP_ADDRESS_LENGTH_BYTES ],
|
BaseType_t FreeRTOS_IPInit( const uint8_t ucIPAddress[ ipIP_ADDRESS_LENGTH_BYTES ],
|
||||||
const uint8_t ucNetMask[ ipIP_ADDRESS_LENGTH_BYTES ],
|
const uint8_t ucNetMask[ ipIP_ADDRESS_LENGTH_BYTES ],
|
||||||
const uint8_t ucGatewayAddress[ ipIP_ADDRESS_LENGTH_BYTES ],
|
const uint8_t ucGatewayAddress[ ipIP_ADDRESS_LENGTH_BYTES ],
|
||||||
@@ -1171,7 +1178,7 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE
|
|||||||
/* Map the buffer onto Ethernet Header struct for easy access to fields. */
|
/* Map the buffer onto Ethernet Header struct for easy access to fields. */
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
pxEthernetHeader = ( ( const EthernetHeader_t * ) pucEthernetBuffer );
|
pxEthernetHeader = ( ( const EthernetHeader_t * ) pucEthernetBuffer );
|
||||||
|
|
||||||
@@ -1245,7 +1252,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor
|
|||||||
/* Map the buffer onto the Ethernet Header struct for easy access to the fields. */
|
/* Map the buffer onto the Ethernet Header struct for easy access to the fields. */
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
pxEthernetHeader = ( ( const EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer );
|
pxEthernetHeader = ( ( const EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer );
|
||||||
|
|
||||||
@@ -1263,7 +1270,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor
|
|||||||
if( pxNetworkBuffer->xDataLength >= sizeof( ARPPacket_t ) )
|
if( pxNetworkBuffer->xDataLength >= sizeof( ARPPacket_t ) )
|
||||||
{
|
{
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
eReturned = eARPProcessPacket( ( ( ARPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ) );
|
eReturned = eARPProcessPacket( ( ( ARPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ) );
|
||||||
}
|
}
|
||||||
@@ -1280,7 +1287,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor
|
|||||||
if( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_t ) )
|
if( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_t ) )
|
||||||
{
|
{
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
eReturned = prvProcessIPPacket( ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ), pxNetworkBuffer );
|
eReturned = prvProcessIPPacket( ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ), pxNetworkBuffer );
|
||||||
}
|
}
|
||||||
@@ -1542,7 +1549,7 @@ static eFrameProcessingResult_t prvAllowIPPacket( const IPPacket_t * const pxIPP
|
|||||||
/* pxProtPack will point to the offset were the protocols begin. */
|
/* pxProtPack will point to the offset were the protocols begin. */
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
pxProtPack = ( ( ProtocolPacket_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ uxHeaderLength - ipSIZE_OF_IPv4_HEADER ] ) );
|
pxProtPack = ( ( ProtocolPacket_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ uxHeaderLength - ipSIZE_OF_IPv4_HEADER ] ) );
|
||||||
|
|
||||||
@@ -1610,6 +1617,10 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket,
|
|||||||
/* Check if the IP headers are acceptable and if it has our destination. */
|
/* Check if the IP headers are acceptable and if it has our destination. */
|
||||||
eReturn = prvAllowIPPacket( pxIPPacket, pxNetworkBuffer, uxHeaderLength );
|
eReturn = prvAllowIPPacket( pxIPPacket, pxNetworkBuffer, uxHeaderLength );
|
||||||
|
|
||||||
|
/* MISRA Ref 14.3.1 [Configuration dependent invariant] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-143 */
|
||||||
|
/* coverity[misra_c_2012_rule_14_3_violation] */
|
||||||
|
/* coverity[cond_const] */
|
||||||
if( eReturn == eProcessBuffer )
|
if( eReturn == eProcessBuffer )
|
||||||
{
|
{
|
||||||
/* Are there IP-options. */
|
/* Are there IP-options. */
|
||||||
@@ -1647,8 +1658,9 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* MISRA Ref 14.3.1 [Configuration dependent invariant] */
|
/* MISRA Ref 14.3.1 [Configuration dependent invariant] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-143 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-143 */
|
||||||
/* coverity[misra_c_2012_rule_14_3_violation] */
|
/* coverity[misra_c_2012_rule_14_3_violation] */
|
||||||
|
/* coverity[const] */
|
||||||
if( eReturn != eReleaseBuffer )
|
if( eReturn != eReleaseBuffer )
|
||||||
{
|
{
|
||||||
/* Add the IP and MAC addresses to the ARP table if they are not
|
/* Add the IP and MAC addresses to the ARP table if they are not
|
||||||
@@ -1838,7 +1850,7 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket,
|
|||||||
* fields of the IP packet. */
|
* fields of the IP packet. */
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
pxIPPacket = ( ( const IPPacket_t * ) pucEthernetBuffer );
|
pxIPPacket = ( ( const IPPacket_t * ) pucEthernetBuffer );
|
||||||
|
|
||||||
@@ -1991,7 +2003,7 @@ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer,
|
|||||||
/* Map the Buffer to Ethernet Header struct for easy access to fields. */
|
/* Map the Buffer to Ethernet Header struct for easy access to fields. */
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
pxEthernetHeader = ( ( EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer );
|
pxEthernetHeader = ( ( EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer );
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
/* MISRA Ref 8.9.1 [File scoped variables] */
|
/* MISRA Ref 8.9.1 [File scoped variables] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-89 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-89 */
|
||||||
/* coverity[misra_c_2012_rule_8_9_violation] */
|
/* coverity[misra_c_2012_rule_8_9_violation] */
|
||||||
|
/* coverity[single_use] */
|
||||||
static BaseType_t xCallEventHook = pdFALSE;
|
static BaseType_t xCallEventHook = pdFALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -974,10 +975,10 @@ uint16_t usGenerateChecksum( uint16_t usSum,
|
|||||||
/* coverity[value_overwrite] */
|
/* coverity[value_overwrite] */
|
||||||
xSum.u32 = ( uint32_t ) xSum.u16[ 0 ] + xSum.u16[ 1 ];
|
xSum.u32 = ( uint32_t ) xSum.u16[ 0 ] + xSum.u16[ 1 ];
|
||||||
|
|
||||||
/* coverity[value_overwrite] */
|
|
||||||
/* MISRA Ref 2.2.1 [Unions and dead code] */
|
/* MISRA Ref 2.2.1 [Unions and dead code] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-22 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-22 */
|
||||||
/* coverity[misra_c_2012_rule_2_2_violation] */
|
/* coverity[misra_c_2012_rule_2_2_violation] */
|
||||||
|
/* coverity[value_overwrite] */
|
||||||
xSum.u32 = ( uint32_t ) xSum.u16[ 0 ] + xSum.u16[ 1 ];
|
xSum.u32 = ( uint32_t ) xSum.u16[ 0 ] + xSum.u16[ 1 ];
|
||||||
|
|
||||||
if( ( uxAlignBits & 1U ) != 0U )
|
if( ( uxAlignBits & 1U ) != 0U )
|
||||||
|
|||||||
@@ -1533,6 +1533,9 @@ BaseType_t FreeRTOS_closesocket( Socket_t xSocket )
|
|||||||
*
|
*
|
||||||
* @return Returns NULL, always.
|
* @return Returns NULL, always.
|
||||||
*/
|
*/
|
||||||
|
/* MISRA Ref 17.2.1 [Sockets and limited recursion] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-172 */
|
||||||
|
/* coverity[misra_c_2012_rule_17_2_violation] */
|
||||||
void * vSocketClose( FreeRTOS_Socket_t * pxSocket )
|
void * vSocketClose( FreeRTOS_Socket_t * pxSocket )
|
||||||
{
|
{
|
||||||
NetworkBufferDescriptor_t * pxNetworkBuffer;
|
NetworkBufferDescriptor_t * pxNetworkBuffer;
|
||||||
@@ -1645,12 +1648,16 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket )
|
|||||||
*
|
*
|
||||||
* @param[in] pxSocketToDelete: The socket being closed.
|
* @param[in] pxSocketToDelete: The socket being closed.
|
||||||
*/
|
*/
|
||||||
|
/* MISRA Ref 17.2.1 [Sockets and limited recursion] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-172 */
|
||||||
|
/* coverity[misra_c_2012_rule_17_2_violation] */
|
||||||
|
/* coverity[recursive_step] */
|
||||||
static void prvTCPSetSocketCount( FreeRTOS_Socket_t const * pxSocketToDelete )
|
static void prvTCPSetSocketCount( FreeRTOS_Socket_t const * pxSocketToDelete )
|
||||||
{
|
{
|
||||||
const ListItem_t * pxIterator;
|
const ListItem_t * pxIterator;
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
|
const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
|
||||||
FreeRTOS_Socket_t * pxOtherSocket;
|
FreeRTOS_Socket_t * pxOtherSocket;
|
||||||
@@ -1673,8 +1680,9 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket )
|
|||||||
( pxOtherSocket->u.xTCP.bits.bPassAccept != pdFALSE_UNSIGNED ) ) )
|
( pxOtherSocket->u.xTCP.bits.bPassAccept != pdFALSE_UNSIGNED ) ) )
|
||||||
{
|
{
|
||||||
/* MISRA Ref 17.2.1 [Sockets and limited recursion] */
|
/* MISRA Ref 17.2.1 [Sockets and limited recursion] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-172 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-172 */
|
||||||
/* coverity[misra_c_2012_rule_17_2_violation] */
|
/* coverity[misra_c_2012_rule_17_2_violation] */
|
||||||
|
/* coverity[recursive_step] */
|
||||||
( void ) vSocketClose( pxOtherSocket );
|
( void ) vSocketClose( pxOtherSocket );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1957,8 +1965,13 @@ BaseType_t FreeRTOS_setsockopt( Socket_t xSocket,
|
|||||||
* type "B" removes const qualifier from the pointed to type. */
|
* type "B" removes const qualifier from the pointed to type. */
|
||||||
|
|
||||||
/* MISRA Ref 11.8.1 [Function pointer and use of const pointer] */
|
/* MISRA Ref 11.8.1 [Function pointer and use of const pointer] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-118 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-118 */
|
||||||
|
|
||||||
|
/* MISRA Ref 11.1.1 [ Conversion between pointer to
|
||||||
|
* a function and another type ] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-111 */
|
||||||
/* coverity[misra_c_2012_rule_11_8_violation] */
|
/* coverity[misra_c_2012_rule_11_8_violation] */
|
||||||
|
/* coverity[misra_c_2012_rule_11_1_violation] */
|
||||||
pxSocket->pxUserWakeCallback = ( SocketWakeupCallback_t ) pvOptionValue;
|
pxSocket->pxUserWakeCallback = ( SocketWakeupCallback_t ) pvOptionValue;
|
||||||
xReturn = 0;
|
xReturn = 0;
|
||||||
break;
|
break;
|
||||||
@@ -2242,7 +2255,7 @@ static const ListItem_t * pxListFindListItemWithValue( const List_t * pxList,
|
|||||||
const ListItem_t * pxIterator;
|
const ListItem_t * pxIterator;
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( pxList->xListEnd ) );
|
const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( pxList->xListEnd ) );
|
||||||
|
|
||||||
@@ -3166,7 +3179,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket )
|
|||||||
/* Not a valid socket or wrong type */
|
/* Not a valid socket or wrong type */
|
||||||
|
|
||||||
/* MISRA Ref 11.4.1 [Socket error and integer to pointer conversion] */
|
/* MISRA Ref 11.4.1 [Socket error and integer to pointer conversion] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
|
||||||
/* coverity[misra_c_2012_rule_11_4_violation] */
|
/* coverity[misra_c_2012_rule_11_4_violation] */
|
||||||
pxClientSocket = FREERTOS_INVALID_SOCKET;
|
pxClientSocket = FREERTOS_INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
@@ -3176,7 +3189,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket )
|
|||||||
/* Parent socket is not in listening mode */
|
/* Parent socket is not in listening mode */
|
||||||
|
|
||||||
/* MISRA Ref 11.4.1 [Socket error and integer to pointer conversion] */
|
/* MISRA Ref 11.4.1 [Socket error and integer to pointer conversion] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
|
||||||
/* coverity[misra_c_2012_rule_11_4_violation] */
|
/* coverity[misra_c_2012_rule_11_4_violation] */
|
||||||
pxClientSocket = FREERTOS_INVALID_SOCKET;
|
pxClientSocket = FREERTOS_INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
@@ -3956,12 +3969,12 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket )
|
|||||||
TickType_t xDelta = xNow - xLastTime;
|
TickType_t xDelta = xNow - xLastTime;
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
|
const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
const ListItem_t * pxIterator = ( const ListItem_t * ) listGET_HEAD_ENTRY( &xBoundTCPSocketsList );
|
const ListItem_t * pxIterator = ( const ListItem_t * ) listGET_HEAD_ENTRY( &xBoundTCPSocketsList );
|
||||||
|
|
||||||
@@ -4060,7 +4073,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket )
|
|||||||
FreeRTOS_Socket_t * pxResult = NULL, * pxListenSocket = NULL;
|
FreeRTOS_Socket_t * pxResult = NULL, * pxListenSocket = NULL;
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
|
const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
|
||||||
|
|
||||||
@@ -4707,7 +4720,7 @@ BaseType_t xSocketValid( const ConstSocket_t xSocket )
|
|||||||
BaseType_t xReturnValue = pdFALSE;
|
BaseType_t xReturnValue = pdFALSE;
|
||||||
|
|
||||||
/* MISRA Ref 11.4.1 [Socket error and integer to pointer conversion] */
|
/* MISRA Ref 11.4.1 [Socket error and integer to pointer conversion] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
|
||||||
/* coverity[misra_c_2012_rule_11_4_violation] */
|
/* coverity[misra_c_2012_rule_11_4_violation] */
|
||||||
if( ( xSocket != FREERTOS_INVALID_SOCKET ) && ( xSocket != NULL ) )
|
if( ( xSocket != FREERTOS_INVALID_SOCKET ) && ( xSocket != NULL ) )
|
||||||
{
|
{
|
||||||
@@ -4881,7 +4894,7 @@ BaseType_t xSocketValid( const ConstSocket_t xSocket )
|
|||||||
if( xRound == 0 )
|
if( xRound == 0 )
|
||||||
{
|
{
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
pxEnd = ( ( const ListItem_t * ) &( xBoundUDPSocketsList.xListEnd ) );
|
pxEnd = ( ( const ListItem_t * ) &( xBoundUDPSocketsList.xListEnd ) );
|
||||||
}
|
}
|
||||||
@@ -4890,7 +4903,7 @@ BaseType_t xSocketValid( const ConstSocket_t xSocket )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
|
pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,9 +65,6 @@
|
|||||||
#if ipconfigUSE_TCP == 1
|
#if ipconfigUSE_TCP == 1
|
||||||
|
|
||||||
|
|
||||||
/* MISRA Ref 8.9.1 [File scoped variables] */
|
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-89 */
|
|
||||||
/* coverity[misra_c_2012_rule_8_9_violation] */
|
|
||||||
|
|
||||||
/** @brief When closing a socket an event is posted to the Network Event Queue.
|
/** @brief When closing a socket an event is posted to the Network Event Queue.
|
||||||
* If the queue is full, then the event is not posted and the socket
|
* If the queue is full, then the event is not posted and the socket
|
||||||
@@ -75,6 +72,9 @@
|
|||||||
* track of any socket which needs to be closed. This variable can be
|
* track of any socket which needs to be closed. This variable can be
|
||||||
* accessed by the IP task only. Thus, preventing any race condition.
|
* accessed by the IP task only. Thus, preventing any race condition.
|
||||||
*/
|
*/
|
||||||
|
/* MISRA Ref 8.9.1 [File scoped variables] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-89 */
|
||||||
|
/* coverity[misra_c_2012_rule_8_9_violation] */
|
||||||
static FreeRTOS_Socket_t * xPreviousSocket = NULL;
|
static FreeRTOS_Socket_t * xPreviousSocket = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -107,6 +107,7 @@
|
|||||||
*
|
*
|
||||||
* @param[in] pxSocket: The socket to be checked.
|
* @param[in] pxSocket: The socket to be checked.
|
||||||
*/
|
*/
|
||||||
|
/* coverity[single_use] */
|
||||||
void vSocketCloseNextTime( FreeRTOS_Socket_t * pxSocket )
|
void vSocketCloseNextTime( FreeRTOS_Socket_t * pxSocket )
|
||||||
{
|
{
|
||||||
if( ( xPreviousSocket != NULL ) && ( xPreviousSocket != pxSocket ) )
|
if( ( xPreviousSocket != NULL ) && ( xPreviousSocket != pxSocket ) )
|
||||||
@@ -552,7 +553,7 @@
|
|||||||
/* Map the buffer onto a ProtocolHeaders_t struct for easy access to the fields. */
|
/* Map the buffer onto a ProtocolHeaders_t struct for easy access to the fields. */
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
const ProtocolHeaders_t * pxProtocolHeaders = ( ( const ProtocolHeaders_t * )
|
const ProtocolHeaders_t * pxProtocolHeaders = ( ( const ProtocolHeaders_t * )
|
||||||
&( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + xIPHeaderSize( pxNetworkBuffer ) ] ) );
|
&( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + xIPHeaderSize( pxNetworkBuffer ) ] ) );
|
||||||
@@ -578,7 +579,7 @@
|
|||||||
/* Map the ethernet buffer onto the IPHeader_t struct for easy access to the fields. */
|
/* Map the ethernet buffer onto the IPHeader_t struct for easy access to the fields. */
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
pxIPHeader = ( ( const IPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] ) );
|
pxIPHeader = ( ( const IPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] ) );
|
||||||
ulLocalIP = FreeRTOS_htonl( pxIPHeader->ulDestinationIPAddress );
|
ulLocalIP = FreeRTOS_htonl( pxIPHeader->ulDestinationIPAddress );
|
||||||
@@ -810,7 +811,7 @@
|
|||||||
BaseType_t xResult = pdFALSE;
|
BaseType_t xResult = pdFALSE;
|
||||||
|
|
||||||
/* MISRA Ref 11.3.1 [Misaligned access] */
|
/* MISRA Ref 11.3.1 [Misaligned access] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
|
||||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||||
const ListItem_t * pxEndTCP = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
|
const ListItem_t * pxEndTCP = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) );
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,7 @@
|
|||||||
* stack. FreeRTOS includes optional stack overflow detection, see:
|
* stack. FreeRTOS includes optional stack overflow detection, see:
|
||||||
* http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
|
* http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
|
||||||
#ifndef ipconfigIP_TASK_STACK_SIZE_WORDS
|
#ifndef ipconfigIP_TASK_STACK_SIZE_WORDS
|
||||||
#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
|
#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5U )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Include all API's and code that is needed for the TCP protocol.
|
/* Include all API's and code that is needed for the TCP protocol.
|
||||||
@@ -259,6 +259,9 @@
|
|||||||
|
|
||||||
#ifndef FreeRTOS_debug_printf
|
#ifndef FreeRTOS_debug_printf
|
||||||
#define FreeRTOS_debug_printf( MSG ) do {} while( ipFALSE_BOOL )
|
#define FreeRTOS_debug_printf( MSG ) do {} while( ipFALSE_BOOL )
|
||||||
|
/* MISRA Ref 20.5.1 [Use of undef] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2051 */
|
||||||
|
/* coverity[misra_c_2012_rule_20_5_violation] */
|
||||||
#undef ipconfigHAS_DEBUG_PRINTF
|
#undef ipconfigHAS_DEBUG_PRINTF
|
||||||
#define ipconfigHAS_DEBUG_PRINTF 0
|
#define ipconfigHAS_DEBUG_PRINTF 0
|
||||||
#endif
|
#endif
|
||||||
@@ -282,6 +285,9 @@
|
|||||||
|
|
||||||
#ifndef FreeRTOS_printf
|
#ifndef FreeRTOS_printf
|
||||||
#define FreeRTOS_printf( MSG ) do {} while( ipFALSE_BOOL )
|
#define FreeRTOS_printf( MSG ) do {} while( ipFALSE_BOOL )
|
||||||
|
/* MISRA Ref 20.5.1 [Use of undef] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2051 */
|
||||||
|
/* coverity[misra_c_2012_rule_20_5_violation] */
|
||||||
#undef ipconfigHAS_PRINTF
|
#undef ipconfigHAS_PRINTF
|
||||||
#define ipconfigHAS_PRINTF 0
|
#define ipconfigHAS_PRINTF 0
|
||||||
#endif
|
#endif
|
||||||
@@ -611,6 +617,9 @@
|
|||||||
#else
|
#else
|
||||||
/* A sanity check to avoid a possible overflow of size_t. */
|
/* A sanity check to avoid a possible overflow of size_t. */
|
||||||
#if ipconfigNETWORK_MTU > ( SIZE_MAX >> 1 )
|
#if ipconfigNETWORK_MTU > ( SIZE_MAX >> 1 )
|
||||||
|
/* MISRA Ref 20.5.1 [Use of undef] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2051 */
|
||||||
|
/* coverity[misra_c_2012_rule_20_5_violation] */
|
||||||
#undef ipconfigNETWORK_MTU
|
#undef ipconfigNETWORK_MTU
|
||||||
#define ipconfigNETWORK_MTU ( SIZE_MAX >> 1 )
|
#define ipconfigNETWORK_MTU ( SIZE_MAX >> 1 )
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -215,13 +215,15 @@ uint8_t * pucGetNetworkBuffer( size_t * pxRequestedSizeBytes )
|
|||||||
|
|
||||||
void vReleaseNetworkBuffer( uint8_t * pucEthernetBuffer )
|
void vReleaseNetworkBuffer( uint8_t * pucEthernetBuffer )
|
||||||
{
|
{
|
||||||
|
uint8_t * pucEthernetBufferCopy = pucEthernetBuffer;
|
||||||
|
|
||||||
/* There is space before the Ethernet buffer in which a pointer to the
|
/* There is space before the Ethernet buffer in which a pointer to the
|
||||||
* network buffer that references this Ethernet buffer is stored. Remove the
|
* network buffer that references this Ethernet buffer is stored. Remove the
|
||||||
* space before freeing the buffer. */
|
* space before freeing the buffer. */
|
||||||
if( pucEthernetBuffer != NULL )
|
if( pucEthernetBufferCopy != NULL )
|
||||||
{
|
{
|
||||||
pucEthernetBuffer -= ipBUFFER_PADDING;
|
pucEthernetBufferCopy -= ipBUFFER_PADDING;
|
||||||
vPortFree( ( void * ) pucEthernetBuffer );
|
vPortFree( ( void * ) pucEthernetBufferCopy );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
@@ -232,8 +234,9 @@ NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedS
|
|||||||
NetworkBufferDescriptor_t * pxReturn = NULL;
|
NetworkBufferDescriptor_t * pxReturn = NULL;
|
||||||
size_t uxCount;
|
size_t uxCount;
|
||||||
size_t uxMaxAllowedBytes = ( SIZE_MAX >> 1 );
|
size_t uxMaxAllowedBytes = ( SIZE_MAX >> 1 );
|
||||||
|
size_t xRequestedSizeBytesCopy = xRequestedSizeBytes;
|
||||||
|
|
||||||
if( ( xRequestedSizeBytes <= uxMaxAllowedBytes ) && ( xNetworkBufferSemaphore != NULL ) )
|
if( ( xRequestedSizeBytesCopy <= uxMaxAllowedBytes ) && ( xNetworkBufferSemaphore != NULL ) )
|
||||||
{
|
{
|
||||||
/* If there is a semaphore available, there is a network buffer available. */
|
/* If there is a semaphore available, there is a network buffer available. */
|
||||||
if( xSemaphoreTake( xNetworkBufferSemaphore, xBlockTimeTicks ) == pdPASS )
|
if( xSemaphoreTake( xNetworkBufferSemaphore, xBlockTimeTicks ) == pdPASS )
|
||||||
@@ -257,27 +260,27 @@ NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedS
|
|||||||
/* Allocate storage of exactly the requested size to the buffer. */
|
/* Allocate storage of exactly the requested size to the buffer. */
|
||||||
configASSERT( pxReturn->pucEthernetBuffer == NULL );
|
configASSERT( pxReturn->pucEthernetBuffer == NULL );
|
||||||
|
|
||||||
if( xRequestedSizeBytes > 0U )
|
if( xRequestedSizeBytesCopy > 0U )
|
||||||
{
|
{
|
||||||
if( ( xRequestedSizeBytes < ( size_t ) baMINIMAL_BUFFER_SIZE ) )
|
if( ( xRequestedSizeBytesCopy < ( size_t ) baMINIMAL_BUFFER_SIZE ) )
|
||||||
{
|
{
|
||||||
/* ARP packets can replace application packets, so the storage must be
|
/* ARP packets can replace application packets, so the storage must be
|
||||||
* at least large enough to hold an ARP. */
|
* at least large enough to hold an ARP. */
|
||||||
xRequestedSizeBytes = baMINIMAL_BUFFER_SIZE;
|
xRequestedSizeBytesCopy = baMINIMAL_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add 2 bytes to xRequestedSizeBytes and round up xRequestedSizeBytes
|
/* Add 2 bytes to xRequestedSizeBytesCopy and round up xRequestedSizeBytesCopy
|
||||||
* to the nearest multiple of N bytes, where N equals 'sizeof( size_t )'. */
|
* to the nearest multiple of N bytes, where N equals 'sizeof( size_t )'. */
|
||||||
xRequestedSizeBytes += 2U;
|
xRequestedSizeBytesCopy += 2U;
|
||||||
|
|
||||||
if( ( xRequestedSizeBytes & ( sizeof( size_t ) - 1U ) ) != 0U )
|
if( ( xRequestedSizeBytesCopy & ( sizeof( size_t ) - 1U ) ) != 0U )
|
||||||
{
|
{
|
||||||
xRequestedSizeBytes = ( xRequestedSizeBytes | ( sizeof( size_t ) - 1U ) ) + 1U;
|
xRequestedSizeBytesCopy = ( xRequestedSizeBytesCopy | ( sizeof( size_t ) - 1U ) ) + 1U;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extra space is obtained so a pointer to the network buffer can
|
/* Extra space is obtained so a pointer to the network buffer can
|
||||||
* be stored at the beginning of the buffer. */
|
* be stored at the beginning of the buffer. */
|
||||||
pxReturn->pucEthernetBuffer = ( uint8_t * ) pvPortMalloc( xRequestedSizeBytes + ipBUFFER_PADDING );
|
pxReturn->pucEthernetBuffer = ( uint8_t * ) pvPortMalloc( xRequestedSizeBytesCopy + ipBUFFER_PADDING );
|
||||||
|
|
||||||
if( pxReturn->pucEthernetBuffer == NULL )
|
if( pxReturn->pucEthernetBuffer == NULL )
|
||||||
{
|
{
|
||||||
@@ -293,12 +296,15 @@ NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedS
|
|||||||
* buffer storage area, then move the buffer pointer on past the
|
* buffer storage area, then move the buffer pointer on past the
|
||||||
* stored pointer so the pointer value is not overwritten by the
|
* stored pointer so the pointer value is not overwritten by the
|
||||||
* application when the buffer is used. */
|
* application when the buffer is used. */
|
||||||
|
/* 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] */
|
||||||
*( ( NetworkBufferDescriptor_t ** ) ( pxReturn->pucEthernetBuffer ) ) = pxReturn;
|
*( ( NetworkBufferDescriptor_t ** ) ( pxReturn->pucEthernetBuffer ) ) = pxReturn;
|
||||||
pxReturn->pucEthernetBuffer += ipBUFFER_PADDING;
|
pxReturn->pucEthernetBuffer += ipBUFFER_PADDING;
|
||||||
|
|
||||||
/* Store the actual size of the allocated buffer, which may be
|
/* Store the actual size of the allocated buffer, which may be
|
||||||
* greater than the original requested size. */
|
* greater than the original requested size. */
|
||||||
pxReturn->xDataLength = xRequestedSizeBytes;
|
pxReturn->xDataLength = xRequestedSizeBytesCopy;
|
||||||
|
|
||||||
#if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 )
|
#if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 )
|
||||||
{
|
{
|
||||||
@@ -393,30 +399,36 @@ NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDe
|
|||||||
{
|
{
|
||||||
size_t xOriginalLength;
|
size_t xOriginalLength;
|
||||||
uint8_t * pucBuffer;
|
uint8_t * pucBuffer;
|
||||||
|
size_t uxSizeBytes = xNewSizeBytes;
|
||||||
|
NetworkBufferDescriptor_t * pxNetworkBufferCopy = pxNetworkBuffer;
|
||||||
|
|
||||||
xOriginalLength = pxNetworkBuffer->xDataLength + ipBUFFER_PADDING;
|
|
||||||
xNewSizeBytes = xNewSizeBytes + ipBUFFER_PADDING;
|
|
||||||
|
|
||||||
pucBuffer = pucGetNetworkBuffer( &( xNewSizeBytes ) );
|
|
||||||
|
xOriginalLength = pxNetworkBufferCopy->xDataLength + ipBUFFER_PADDING;
|
||||||
|
uxSizeBytes = uxSizeBytes + ipBUFFER_PADDING;
|
||||||
|
|
||||||
|
pucBuffer = pucGetNetworkBuffer( &( uxSizeBytes ) );
|
||||||
|
|
||||||
if( pucBuffer == NULL )
|
if( pucBuffer == NULL )
|
||||||
{
|
{
|
||||||
/* In case the allocation fails, return NULL. */
|
/* In case the allocation fails, return NULL. */
|
||||||
pxNetworkBuffer = NULL;
|
pxNetworkBufferCopy = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pxNetworkBuffer->xDataLength = xNewSizeBytes;
|
pxNetworkBufferCopy->xDataLength = uxSizeBytes;
|
||||||
|
|
||||||
if( xNewSizeBytes > xOriginalLength )
|
if( uxSizeBytes > xOriginalLength )
|
||||||
{
|
{
|
||||||
xNewSizeBytes = xOriginalLength;
|
uxSizeBytes = xOriginalLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
( void ) memcpy( pucBuffer - ipBUFFER_PADDING, pxNetworkBuffer->pucEthernetBuffer - ipBUFFER_PADDING, xNewSizeBytes );
|
( void ) memcpy( pucBuffer - ipBUFFER_PADDING,
|
||||||
vReleaseNetworkBuffer( pxNetworkBuffer->pucEthernetBuffer );
|
pxNetworkBufferCopy->pucEthernetBuffer - ipBUFFER_PADDING,
|
||||||
pxNetworkBuffer->pucEthernetBuffer = pucBuffer;
|
uxSizeBytes );
|
||||||
|
vReleaseNetworkBuffer( pxNetworkBufferCopy->pucEthernetBuffer );
|
||||||
|
pxNetworkBufferCopy->pucEthernetBuffer = pucBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pxNetworkBuffer;
|
return pxNetworkBufferCopy;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ project ( "FreeRTOS+TCP Static analysis"
|
|||||||
|
|
||||||
# Allow the project to be organized into folders.
|
# Allow the project to be organized into folders.
|
||||||
set_property( GLOBAL PROPERTY USE_FOLDERS ON )
|
set_property( GLOBAL PROPERTY USE_FOLDERS ON )
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
|
|
||||||
# Use C90.
|
# Use C90.
|
||||||
set( CMAKE_C_STANDARD 90 )
|
set( CMAKE_C_STANDARD 90 )
|
||||||
|
|||||||
@@ -105,7 +105,7 @@
|
|||||||
* number generation is performed via this macro to allow applications to use their
|
* number generation is performed via this macro to allow applications to use their
|
||||||
* own random number generation method. For example, it might be possible to
|
* own random number generation method. For example, it might be possible to
|
||||||
* generate a random number by sampling noise on an analogue input. */
|
* generate a random number by sampling noise on an analogue input. */
|
||||||
extern uint32_t ulRand();
|
extern uint32_t ulRand( void );
|
||||||
#define ipconfigRAND32() ulRand()
|
#define ipconfigRAND32() ulRand()
|
||||||
|
|
||||||
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
|
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
|
||||||
|
|||||||
@@ -53,6 +53,19 @@
|
|||||||
{
|
{
|
||||||
deviation: "Rule 15.4",
|
deviation: "Rule 15.4",
|
||||||
reason: "Multiple breaks in a do { ... } while ( 0 ); block are used to make the code easier to read and more clean than using multiple nested if-else statements."
|
reason: "Multiple breaks in a do { ... } while ( 0 ); block are used to make the code easier to read and more clean than using multiple nested if-else statements."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deviation: "Rule 11.5",
|
||||||
|
reason: "Conversion from pointer to void into pointer to object
|
||||||
|
all uses are checked and tested not to cause misalignment, pointers
|
||||||
|
are switched back to their original type before they are accessed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deviation: "Rule 8.6",
|
||||||
|
reason: "We use function callbacks to be defined by the application
|
||||||
|
writer, we could not provide definitions under the risk of
|
||||||
|
multiple definitions"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user