From 35d787dbd9c844772eda9447861fe1d3110750e8 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Thu, 28 Jul 2022 16:08:28 -0700 Subject: [PATCH 01/23] Fix Remaning misra issues --- MISRA.md | 7 +++++++ source/FreeRTOS_IP.c | 5 ++++- source/FreeRTOS_Sockets.c | 15 +++++++++++++-- source/include/FreeRTOSIPConfigDefaults.h | 2 +- tools/coverity_misra.config | 6 ++++++ 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/MISRA.md b/MISRA.md index 2cc207d03c..6040c0001e 100644 --- a/MISRA.md +++ b/MISRA.md @@ -31,6 +31,13 @@ _Ref 8.9.1_ order of execution, some variables have file scope definitions rather than function scope. +#### Rule 11.1 +_Ref 11.1.1_ + +- MISRA C-2012 Rule 11.1 Converting from a void pointer to a function pointer, + it is part of the API and the user is responsible of providing that pointer + and their responsibility for that pointer to be valid. + #### Rule 11.3 _Ref 11.3.1_ diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 58ca748898..99b71408f5 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1610,6 +1610,9 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket, /* Check if the IP headers are acceptable and if it has our destination. */ 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] */ if( eReturn == eProcessBuffer ) { /* Are there IP-options. */ @@ -1647,7 +1650,7 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket, } /* 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] */ if( eReturn != eReleaseBuffer ) { diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index a6f024eee9..bda8a31255 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -1533,6 +1533,9 @@ BaseType_t FreeRTOS_closesocket( Socket_t xSocket ) * * @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 ) { NetworkBufferDescriptor_t * pxNetworkBuffer; @@ -1645,12 +1648,15 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) * * @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] */ static void prvTCPSetSocketCount( FreeRTOS_Socket_t const * pxSocketToDelete ) { const ListItem_t * pxIterator; /* 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] */ const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) ); FreeRTOS_Socket_t * pxOtherSocket; @@ -1957,8 +1963,13 @@ BaseType_t FreeRTOS_setsockopt( Socket_t xSocket, * type "B" removes const qualifier from the pointed to type. */ /* 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 */ /* coverity[misra_c_2012_rule_11_8_violation] */ + + /* MISRA Ref _Ref 11.1.1_ [ Conversion betwee 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_1_violation] */ pxSocket->pxUserWakeCallback = ( SocketWakeupCallback_t ) pvOptionValue; xReturn = 0; break; diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index 8fa9a11740..2a34f3df03 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -168,7 +168,7 @@ * stack. FreeRTOS includes optional stack overflow detection, see: * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */ #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 /* Include all API's and code that is needed for the TCP protocol. diff --git a/tools/coverity_misra.config b/tools/coverity_misra.config index 9cb41a5b0d..b9c8ddf1e0 100644 --- a/tools/coverity_misra.config +++ b/tools/coverity_misra.config @@ -53,6 +53,12 @@ { 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." + }, + { + 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" } ] } From a76d481c8831a31954bdf439db651786febd8836 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Thu, 28 Jul 2022 16:24:07 -0700 Subject: [PATCH 02/23] Suppress rule 8.6 --- tools/coverity_misra.config | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/coverity_misra.config b/tools/coverity_misra.config index b9c8ddf1e0..8b0015167a 100644 --- a/tools/coverity_misra.config +++ b/tools/coverity_misra.config @@ -57,8 +57,16 @@ { 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" + 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" + + } ] } From 18dfde3b23a389f849b5091930cb2b214bd34721 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Thu, 28 Jul 2022 17:11:06 -0700 Subject: [PATCH 03/23] Fix/Suppress more misra violations --- MISRA.md | 7 ++++ source/FreeRTOS_IP.c | 2 +- source/include/FreeRTOSIPConfigDefaults.h | 9 ++++ .../BufferManagement/BufferAllocation_2.c | 42 +++++++++++-------- test/Coverity/ConfigFiles/FreeRTOSIPConfig.h | 2 +- 5 files changed, 42 insertions(+), 20 deletions(-) diff --git a/MISRA.md b/MISRA.md index 6040c0001e..8958227b92 100644 --- a/MISRA.md +++ b/MISRA.md @@ -135,6 +135,13 @@ _Ref 17.2.1_ have a secondary child socket thereby limiting the number of recursive calls to one. +#### Rule 20.5 +_Ref 20.5.1_ + +- MISRA C-2012 Rule 20.10 warns against the use of #undef + However, in this case, it must be used to make sure some macros are + defined to a certain value + #### Rule 20.10 _Ref 20.10.1_ diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 99b71408f5..aaae07c1db 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1171,7 +1171,7 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* Map the buffer onto Ethernet Header struct for easy access to fields. */ /* 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] */ pxEthernetHeader = ( ( const EthernetHeader_t * ) pucEthernetBuffer ); diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index 2a34f3df03..5d8e816f5f 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -259,6 +259,9 @@ #ifndef FreeRTOS_debug_printf #define FreeRTOS_debug_printf( MSG ) do {} while( ipFALSE_BOOL ) + /* MISRA Ref 20.5.1 [Misaligned access] */ + /* 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 #define ipconfigHAS_DEBUG_PRINTF 0 #endif @@ -282,6 +285,9 @@ #ifndef FreeRTOS_printf #define FreeRTOS_printf( MSG ) do {} while( ipFALSE_BOOL ) + /* MISRA Ref 20.5.1 [Misaligned access] */ + /* 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 #define ipconfigHAS_PRINTF 0 #endif @@ -611,6 +617,9 @@ #else /* A sanity check to avoid a possible overflow of size_t. */ #if ipconfigNETWORK_MTU > ( SIZE_MAX >> 1 ) + /* MISRA Ref 20.5.1 [Misaligned access] */ + /* 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 #define ipconfigNETWORK_MTU ( SIZE_MAX >> 1 ) #endif diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index 9681328325..353e4b943c 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -215,13 +215,14 @@ uint8_t * pucGetNetworkBuffer( size_t * pxRequestedSizeBytes ) void vReleaseNetworkBuffer( uint8_t * pucEthernetBuffer ) { + uint8_t * pucEthernetBufferCopy = pucEthernetBuffer; /* There is space before the Ethernet buffer in which a pointer to the * network buffer that references this Ethernet buffer is stored. Remove the * space before freeing the buffer. */ - if( pucEthernetBuffer != NULL ) + if( pucEthernetBufferCopy != NULL ) { - pucEthernetBuffer -= ipBUFFER_PADDING; - vPortFree( ( void * ) pucEthernetBuffer ); + pucEthernetBufferCopy -= ipBUFFER_PADDING; + vPortFree( ( void * ) pucEthernetBufferCopy ); } } /*-----------------------------------------------------------*/ @@ -232,8 +233,9 @@ NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedS NetworkBufferDescriptor_t * pxReturn = NULL; size_t uxCount; 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( xSemaphoreTake( xNetworkBufferSemaphore, xBlockTimeTicks ) == pdPASS ) @@ -257,27 +259,27 @@ NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedS /* Allocate storage of exactly the requested size to the buffer. */ 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 * 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 )'. */ - 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 * 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 ) { @@ -293,12 +295,15 @@ NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedS * buffer storage area, then move the buffer pointer on past the * stored pointer so the pointer value is not overwritten by the * 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; pxReturn->pucEthernetBuffer += ipBUFFER_PADDING; /* Store the actual size of the allocated buffer, which may be * greater than the original requested size. */ - pxReturn->xDataLength = xRequestedSizeBytes; + pxReturn->xDataLength = xRequestedSizeBytesCopy; #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) { @@ -393,11 +398,12 @@ NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDe { size_t xOriginalLength; uint8_t * pucBuffer; + size_t xSizeBytes = xNewSizeBytes; xOriginalLength = pxNetworkBuffer->xDataLength + ipBUFFER_PADDING; - xNewSizeBytes = xNewSizeBytes + ipBUFFER_PADDING; + xSizeBytes = xSizeBytes + ipBUFFER_PADDING; - pucBuffer = pucGetNetworkBuffer( &( xNewSizeBytes ) ); + pucBuffer = pucGetNetworkBuffer( &( xSizeBytes ) ); if( pucBuffer == NULL ) { @@ -406,11 +412,11 @@ NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDe } else { - pxNetworkBuffer->xDataLength = xNewSizeBytes; + pxNetworkBuffer->xDataLength = xSizeBytes ; - if( xNewSizeBytes > xOriginalLength ) + if( xSizeBytes > xOriginalLength ) { - xNewSizeBytes = xOriginalLength; + xSizeBytes = xOriginalLength; } ( void ) memcpy( pucBuffer - ipBUFFER_PADDING, pxNetworkBuffer->pucEthernetBuffer - ipBUFFER_PADDING, xNewSizeBytes ); diff --git a/test/Coverity/ConfigFiles/FreeRTOSIPConfig.h b/test/Coverity/ConfigFiles/FreeRTOSIPConfig.h index 3235cf9415..73174e20c7 100644 --- a/test/Coverity/ConfigFiles/FreeRTOSIPConfig.h +++ b/test/Coverity/ConfigFiles/FreeRTOSIPConfig.h @@ -105,7 +105,7 @@ * 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 * generate a random number by sampling noise on an analogue input. */ -extern uint32_t ulRand(); +extern uint32_t ulRand( void ); #define ipconfigRAND32() ulRand() /* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the From e0c458c2b97bec051fa6347af3fe230831235347 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Fri, 29 Jul 2022 12:04:50 -0700 Subject: [PATCH 04/23] Style: for formatting --- source/portable/BufferManagement/BufferAllocation_2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index 353e4b943c..d43af6c161 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -216,6 +216,7 @@ uint8_t * pucGetNetworkBuffer( size_t * pxRequestedSizeBytes ) void vReleaseNetworkBuffer( uint8_t * pucEthernetBuffer ) { uint8_t * pucEthernetBufferCopy = pucEthernetBuffer; + /* There is space before the Ethernet buffer in which a pointer to the * network buffer that references this Ethernet buffer is stored. Remove the * space before freeing the buffer. */ @@ -412,7 +413,7 @@ NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDe } else { - pxNetworkBuffer->xDataLength = xSizeBytes ; + pxNetworkBuffer->xDataLength = xSizeBytes; if( xSizeBytes > xOriginalLength ) { From 68d597ca808ce02829e411cb458b9d438a0d420b Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Fri, 29 Jul 2022 12:09:32 -0700 Subject: [PATCH 05/23] Style: fix formatting --- tools/coverity_misra.config | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/coverity_misra.config b/tools/coverity_misra.config index 8b0015167a..05432cd2fd 100644 --- a/tools/coverity_misra.config +++ b/tools/coverity_misra.config @@ -65,8 +65,7 @@ reason: "We use function callbacks to be defined by the application writer, we could not provide definitions under the risk of multiple definitions" - - } ] } + From 9541e0d771e5855287636a1f28d8b536243b695a Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Fri, 29 Jul 2022 12:18:22 -0700 Subject: [PATCH 06/23] Style: fix spelling --- source/FreeRTOS_Sockets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index bda8a31255..95dd9cc7be 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -1966,7 +1966,7 @@ BaseType_t FreeRTOS_setsockopt( Socket_t xSocket, /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-118 */ /* coverity[misra_c_2012_rule_11_8_violation] */ - /* MISRA Ref _Ref 11.1.1_ [ Conversion betwee pointer to + /* MISRA Ref _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_1_violation] */ From 13c58cb8b015c111e14f25881c133c4ca563ac09 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Mon, 1 Aug 2022 10:59:26 -0700 Subject: [PATCH 07/23] Fix Rule 11.1 --- source/FreeRTOS_IP.c | 4 ++-- test/Coverity/CMakeLists.txt | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index aaae07c1db..5dec7dd262 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -122,7 +122,7 @@ static void prvProcessIPEventsAndTimers( void ); * from the network hardware drivers and tasks that are using sockets. It also * 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. @@ -229,7 +229,7 @@ static BaseType_t xIPTaskInitialised = pdFALSE; * * @param[in] pvParameters: Not used. */ -static void prvIPTask( const void * pvParameters ) +static void prvIPTask( void * pvParameters ) { /* Just to prevent compiler warnings about unused parameters. */ ( void ) pvParameters; diff --git a/test/Coverity/CMakeLists.txt b/test/Coverity/CMakeLists.txt index ce55c3d9e6..4fe727d3bb 100644 --- a/test/Coverity/CMakeLists.txt +++ b/test/Coverity/CMakeLists.txt @@ -8,6 +8,7 @@ project ( "FreeRTOS+TCP Static analysis" # Allow the project to be organized into folders. set_property( GLOBAL PROPERTY USE_FOLDERS ON ) +set(CMAKE_VERBOSE_MAKEFILE ON) # Use C90. set( CMAKE_C_STANDARD 90 ) @@ -58,4 +59,4 @@ target_include_directories( StaticAnalysis PUBLIC "${MODULE_ROOT_DIR}/source/include" ) # Uncomment the below line if the desired platform is 32-bit -set_target_properties( StaticAnalysis PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" ) +#set_target_properties( StaticAnalysis PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" ) From 57caf76b173f6761e1d9829281741a39a5daf180 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Mon, 1 Aug 2022 12:39:56 -0700 Subject: [PATCH 08/23] Fix undeteced suppressions --- source/FreeRTOS_IP.c | 7 ++++-- source/FreeRTOS_IP_Utils.c | 1 + source/FreeRTOS_Sockets.c | 24 ++++++++++--------- .../BufferManagement/BufferAllocation_2.c | 17 +++++++------ 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 5dec7dd262..605187c145 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -190,6 +190,7 @@ NetworkAddressingParameters_t xNetworkAddressing = { 0, 0, 0, 0, 0 }; /* 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] */ +/* coverity[single_use] */ NetworkAddressingParameters_t xDefaultAddressing = { 0, 0, 0, 0, 0 }; /** @brief Used to ensure network down events cannot be missed when they cannot be @@ -1613,6 +1614,7 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket, /* 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[const] */ if( eReturn == eProcessBuffer ) { /* Are there IP-options. */ @@ -1652,6 +1654,7 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket, /* 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 != eReleaseBuffer ) { /* Add the IP and MAC addresses to the ARP table if they are not @@ -1841,7 +1844,7 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket, * fields of the IP packet. */ /* 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] */ pxIPPacket = ( ( const IPPacket_t * ) pucEthernetBuffer ); @@ -1994,7 +1997,7 @@ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, /* Map the Buffer to Ethernet Header struct for easy access to fields. */ /* 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] */ pxEthernetHeader = ( ( EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer ); diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index f918ef9175..b0b6db87cb 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -78,6 +78,7 @@ /* 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] */ +/* coverity[single_use] */ static BaseType_t xCallEventHook = pdFALSE; #endif diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index 95dd9cc7be..4c098cbf89 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -1651,6 +1651,7 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) /* 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 ) { const ListItem_t * pxIterator; @@ -1679,8 +1680,9 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) ( pxOtherSocket->u.xTCP.bits.bPassAccept != pdFALSE_UNSIGNED ) ) ) { /* 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[recursive_step] */ ( void ) vSocketClose( pxOtherSocket ); } } @@ -1964,11 +1966,11 @@ BaseType_t FreeRTOS_setsockopt( Socket_t xSocket, /* 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 */ - /* coverity[misra_c_2012_rule_11_8_violation] */ /* MISRA Ref _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_1_violation] */ pxSocket->pxUserWakeCallback = ( SocketWakeupCallback_t ) pvOptionValue; xReturn = 0; @@ -2253,7 +2255,7 @@ static const ListItem_t * pxListFindListItemWithValue( const List_t * pxList, const ListItem_t * pxIterator; /* 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] */ const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( pxList->xListEnd ) ); @@ -3177,7 +3179,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /* Not a valid socket or wrong type */ /* 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] */ pxClientSocket = FREERTOS_INVALID_SOCKET; } @@ -3187,7 +3189,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /* Parent socket is not in listening mode */ /* 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] */ pxClientSocket = FREERTOS_INVALID_SOCKET; } @@ -3967,12 +3969,12 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) TickType_t xDelta = xNow - xLastTime; /* 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] */ const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) ); /* 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] */ const ListItem_t * pxIterator = ( const ListItem_t * ) listGET_HEAD_ENTRY( &xBoundTCPSocketsList ); @@ -4071,7 +4073,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) FreeRTOS_Socket_t * pxResult = NULL, * pxListenSocket = NULL; /* 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] */ const ListItem_t * pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) ); @@ -4718,7 +4720,7 @@ BaseType_t xSocketValid( const ConstSocket_t xSocket ) BaseType_t xReturnValue = pdFALSE; /* 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] */ if( ( xSocket != FREERTOS_INVALID_SOCKET ) && ( xSocket != NULL ) ) { @@ -4892,7 +4894,7 @@ BaseType_t xSocketValid( const ConstSocket_t xSocket ) if( xRound == 0 ) { /* 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] */ pxEnd = ( ( const ListItem_t * ) &( xBoundUDPSocketsList.xListEnd ) ); } @@ -4901,7 +4903,7 @@ BaseType_t xSocketValid( const ConstSocket_t xSocket ) else { /* 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] */ pxEnd = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) ); } diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index d43af6c161..660718e002 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -400,8 +400,11 @@ NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDe size_t xOriginalLength; uint8_t * pucBuffer; size_t xSizeBytes = xNewSizeBytes; + NetworkBufferDescriptor_t * pxNetworkBufferCopy = pxNetworkBuffer; - xOriginalLength = pxNetworkBuffer->xDataLength + ipBUFFER_PADDING; + + + xOriginalLength = pxNetworkBufferCopy->xDataLength + ipBUFFER_PADDING; xSizeBytes = xSizeBytes + ipBUFFER_PADDING; pucBuffer = pucGetNetworkBuffer( &( xSizeBytes ) ); @@ -409,21 +412,21 @@ NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDe if( pucBuffer == NULL ) { /* In case the allocation fails, return NULL. */ - pxNetworkBuffer = NULL; + pxNetworkBufferCopy = NULL; } else { - pxNetworkBuffer->xDataLength = xSizeBytes; + pxNetworkBufferCopy->xDataLength = xSizeBytes; if( xSizeBytes > xOriginalLength ) { xSizeBytes = xOriginalLength; } - ( void ) memcpy( pucBuffer - ipBUFFER_PADDING, pxNetworkBuffer->pucEthernetBuffer - ipBUFFER_PADDING, xNewSizeBytes ); - vReleaseNetworkBuffer( pxNetworkBuffer->pucEthernetBuffer ); - pxNetworkBuffer->pucEthernetBuffer = pucBuffer; + ( void ) memcpy( pucBuffer - ipBUFFER_PADDING, pxNetworkBufferCopy->pucEthernetBuffer - ipBUFFER_PADDING, xNewSizeBytes ); + vReleaseNetworkBuffer( pxNetworkBufferCopy->pucEthernetBuffer ); + pxNetworkBufferCopy->pucEthernetBuffer = pucBuffer; } - return pxNetworkBuffer; + return pxNetworkBufferCopy; } From a9dd58de4217c7a5926a3056e22762e8c1ca969d Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Mon, 1 Aug 2022 13:08:55 -0700 Subject: [PATCH 09/23] Enable 32 bits --- test/Coverity/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Coverity/CMakeLists.txt b/test/Coverity/CMakeLists.txt index 4fe727d3bb..b2ae40306f 100644 --- a/test/Coverity/CMakeLists.txt +++ b/test/Coverity/CMakeLists.txt @@ -59,4 +59,4 @@ target_include_directories( StaticAnalysis PUBLIC "${MODULE_ROOT_DIR}/source/include" ) # Uncomment the below line if the desired platform is 32-bit -#set_target_properties( StaticAnalysis PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" ) +set_target_properties( StaticAnalysis PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" ) From d2f5158369edefcf657aa9771f0f02ad58a21570 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Mon, 1 Aug 2022 14:40:03 -0700 Subject: [PATCH 10/23] Fix more misra leftover violations --- source/FreeRTOS_IP.c | 12 ++++++++---- source/FreeRTOS_IP_Utils.c | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 605187c145..97f0ff074d 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -190,7 +190,6 @@ NetworkAddressingParameters_t xNetworkAddressing = { 0, 0, 0, 0, 0 }; /* 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] */ -/* coverity[single_use] */ NetworkAddressingParameters_t xDefaultAddressing = { 0, 0, 0, 0, 0 }; /** @brief Used to ensure network down events cannot be missed when they cannot be @@ -230,6 +229,10 @@ static BaseType_t xIPTaskInitialised = pdFALSE; * * @param[in] pvParameters: Not used. */ + +/* MISRA Ref 8.13.1 [DHCP events and conversion to void] */ +/* 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. */ @@ -391,7 +394,7 @@ static void prvProcessIPEventsAndTimers( void ) eDHCPState_t eState; /* 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] */ uxState = ( uintptr_t ) xReceivedEvent.pvData; /* coverity[misra_c_2012_rule_10_5_violation] */ @@ -709,6 +712,7 @@ void * FreeRTOS_GetUDPPayloadBuffer( size_t uxRequestedSizeBytes, * @return pdPASS if the task was successfully created and added to a ready * 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 ], const uint8_t ucNetMask[ ipIP_ADDRESS_LENGTH_BYTES ], const uint8_t ucGatewayAddress[ ipIP_ADDRESS_LENGTH_BYTES ], @@ -1614,7 +1618,7 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket, /* 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[const] */ + /* coverity[cond_const] */ if( eReturn == eProcessBuffer ) { /* Are there IP-options. */ @@ -1654,7 +1658,7 @@ static eFrameProcessingResult_t prvProcessIPPacket( IPPacket_t * pxIPPacket, /* 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] */ + /* coverity[const] */ if( eReturn != eReleaseBuffer ) { /* Add the IP and MAC addresses to the ARP table if they are not diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index b0b6db87cb..d6a3d043c2 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -975,10 +975,10 @@ uint16_t usGenerateChecksum( uint16_t usSum, /* coverity[value_overwrite] */ xSum.u32 = ( uint32_t ) xSum.u16[ 0 ] + xSum.u16[ 1 ]; - /* coverity[value_overwrite] */ /* 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 */ /* coverity[misra_c_2012_rule_2_2_violation] */ + /* coverity[value_overwrite] */ xSum.u32 = ( uint32_t ) xSum.u16[ 0 ] + xSum.u16[ 1 ]; if( ( uxAlignBits & 1U ) != 0U ) From 15672265c27399581e4b6ce7b420a821407b5797 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Mon, 1 Aug 2022 15:00:41 -0700 Subject: [PATCH 11/23] Add justification for a missed violation --- MISRA.md | 15 +++++++++++++++ source/FreeRTOS_IP.c | 2 ++ 2 files changed, 17 insertions(+) diff --git a/MISRA.md b/MISRA.md index 8958227b92..de29651626 100644 --- a/MISRA.md +++ b/MISRA.md @@ -31,6 +31,21 @@ _Ref 8.9.1_ order of execution, some variables have file scope definitions rather 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. This is a preefined API by the FreeRTOS-kernel function xTaskCreate, + and it depends on the user if they want to use that parameter, making it + const would break the build. + +#### 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_ diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 97f0ff074d..b7db0e626e 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -397,6 +397,8 @@ static void prvProcessIPEventsAndTimers( void ) /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-116 */ /* coverity[misra_c_2012_rule_11_6_violation] */ 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] */ eState = ( eDHCPState_t ) uxState; From 2d2e7458d2d1ea45ef8a088c02a0f674ed42bc68 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Mon, 1 Aug 2022 16:59:09 -0700 Subject: [PATCH 12/23] Fix comment for rule 8.13 --- source/FreeRTOS_IP.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index b7db0e626e..f0798fce88 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -230,7 +230,7 @@ static BaseType_t xIPTaskInitialised = pdFALSE; * @param[in] pvParameters: Not used. */ -/* MISRA Ref 8.13.1 [DHCP events and conversion to void] */ +/* MISRA Ref 8.13.1 [Not decorating a 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 ) @@ -1252,7 +1252,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor /* Map the buffer onto the Ethernet Header struct for easy access to the fields. */ /* 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] */ pxEthernetHeader = ( ( const EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer ); @@ -1270,7 +1270,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor if( pxNetworkBuffer->xDataLength >= sizeof( ARPPacket_t ) ) { /* 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] */ eReturned = eARPProcessPacket( ( ( ARPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ) ); } @@ -1287,7 +1287,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor if( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_t ) ) { /* 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] */ eReturned = prvProcessIPPacket( ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ), pxNetworkBuffer ); } @@ -1549,7 +1549,7 @@ static eFrameProcessingResult_t prvAllowIPPacket( const IPPacket_t * const pxIPP /* pxProtPack will point to the offset were the protocols begin. */ /* 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] */ pxProtPack = ( ( ProtocolPacket_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ uxHeaderLength - ipSIZE_OF_IPv4_HEADER ] ) ); From 40c82c9b401fa96e8f6071d3f79fb380f1c49822 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Tue, 2 Aug 2022 17:10:27 -0700 Subject: [PATCH 13/23] Fix comment --- MISRA.md | 23 ++++++++++++----------- source/FreeRTOS_IP.c | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/MISRA.md b/MISRA.md index de29651626..cfea6dd923 100644 --- a/MISRA.md +++ b/MISRA.md @@ -129,16 +129,6 @@ _Ref 14.3.1_ - MISRA C-2012 Rule 14.3 False positive as the value might be changed 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 _Ref 17.2.1_ @@ -153,7 +143,7 @@ _Ref 17.2.1_ #### Rule 20.5 _Ref 20.5.1_ -- MISRA C-2012 Rule 20.10 warns against the use of #undef +- MISRA C-2012 Rule 20.5 warns against the use of #undef However, in this case, it must be used to make sure some macros are defined to a certain value @@ -164,3 +154,14 @@ _Ref 20.10.1_ However, in this case, it must be used to support compile time assertions in case the preprocessor does not suppport sizeof. This 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. + diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index f0798fce88..0a8ef49e46 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -230,7 +230,7 @@ static BaseType_t xIPTaskInitialised = pdFALSE; * @param[in] pvParameters: Not used. */ -/* MISRA Ref 8.13.1 [Not decorating a const parameter with const] */ +/* 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 ) From e3156cc4922aee655325d040948b7d57a00d463e Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Wed, 3 Aug 2022 11:35:18 -0700 Subject: [PATCH 14/23] fix misra comments --- source/include/FreeRTOSIPConfigDefaults.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index 5d8e816f5f..a573868992 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -259,7 +259,7 @@ #ifndef FreeRTOS_debug_printf #define FreeRTOS_debug_printf( MSG ) do {} while( ipFALSE_BOOL ) - /* MISRA Ref 20.5.1 [Misaligned access] */ + /* 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 @@ -285,7 +285,7 @@ #ifndef FreeRTOS_printf #define FreeRTOS_printf( MSG ) do {} while( ipFALSE_BOOL ) - /* MISRA Ref 20.5.1 [Misaligned access] */ + /* 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 @@ -617,7 +617,7 @@ #else /* A sanity check to avoid a possible overflow of size_t. */ #if ipconfigNETWORK_MTU > ( SIZE_MAX >> 1 ) - /* MISRA Ref 20.5.1 [Misaligned access] */ + /* 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 From 81e90d8ac5bf905159c46b0675b957876336c182 Mon Sep 17 00:00:00 2001 From: alfred gedeon <28123637+alfred2g@users.noreply.github.com> Date: Wed, 3 Aug 2022 11:51:04 -0700 Subject: [PATCH 15/23] Update MISRA.md Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- MISRA.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MISRA.md b/MISRA.md index cfea6dd923..5a8d9943a8 100644 --- a/MISRA.md +++ b/MISRA.md @@ -35,9 +35,12 @@ _Ref 8.9.1_ _Ref 8.13.1_ - MISRA C-2012 Rule 8.13 Parameter passed is never used, should be declared as - const. This is a preefined API by the FreeRTOS-kernel function xTaskCreate, - and it depends on the user if they want to use that parameter, making it - const would break the build. + 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_ From 0ece037ab7647aaa1284c9e4415a1864b3d3d036 Mon Sep 17 00:00:00 2001 From: alfred gedeon <28123637+alfred2g@users.noreply.github.com> Date: Wed, 3 Aug 2022 12:55:42 -0700 Subject: [PATCH 16/23] Update source/FreeRTOS_Sockets.c Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- source/FreeRTOS_Sockets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index 4c098cbf89..719d2ef7ff 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -1967,7 +1967,7 @@ BaseType_t FreeRTOS_setsockopt( Socket_t xSocket, /* 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 */ - /* MISRA Ref _Ref 11.1.1_ [ Conversion between pointer to + /* 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] */ From 6f6d630d638b0ed53572fcb7c2b73c24a311e3cf Mon Sep 17 00:00:00 2001 From: alfred gedeon <28123637+alfred2g@users.noreply.github.com> Date: Wed, 3 Aug 2022 12:55:53 -0700 Subject: [PATCH 17/23] Update source/portable/BufferManagement/BufferAllocation_2.c Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- source/portable/BufferManagement/BufferAllocation_2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index 660718e002..b3beb57b2a 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -399,7 +399,7 @@ NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDe { size_t xOriginalLength; uint8_t * pucBuffer; - size_t xSizeBytes = xNewSizeBytes; + size_t uxSizeBytes = xNewSizeBytes; NetworkBufferDescriptor_t * pxNetworkBufferCopy = pxNetworkBuffer; From fb24ef8ae5a3af109e5c14c3969e1dc0d6802ed1 Mon Sep 17 00:00:00 2001 From: alfred gedeon <28123637+alfred2g@users.noreply.github.com> Date: Wed, 3 Aug 2022 12:56:26 -0700 Subject: [PATCH 18/23] Update MISRA.md Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- MISRA.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MISRA.md b/MISRA.md index 5a8d9943a8..07d595fba7 100644 --- a/MISRA.md +++ b/MISRA.md @@ -52,9 +52,13 @@ _Ref 10.5.1_ #### Rule 11.1 _Ref 11.1.1_ -- MISRA C-2012 Rule 11.1 Converting from a void pointer to a function pointer, - it is part of the API and the user is responsible of providing that pointer - and their responsibility for that pointer to be valid. +- 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 _Ref 11.3.1_ From 46705beaf4d27afe1d2bf0197b96113bb064c058 Mon Sep 17 00:00:00 2001 From: alfred gedeon <28123637+alfred2g@users.noreply.github.com> Date: Wed, 3 Aug 2022 12:56:33 -0700 Subject: [PATCH 19/23] Update MISRA.md Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- MISRA.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MISRA.md b/MISRA.md index 07d595fba7..1fd9a444b6 100644 --- a/MISRA.md +++ b/MISRA.md @@ -150,9 +150,13 @@ _Ref 17.2.1_ #### Rule 20.5 _Ref 20.5.1_ -- MISRA C-2012 Rule 20.5 warns against the use of #undef - However, in this case, it must be used to make sure some macros are - defined to a certain value +- 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 _Ref 20.10.1_ From 561419cb52b88ee42b39166f2bea0d6d3ce46f56 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Wed, 3 Aug 2022 12:57:47 -0700 Subject: [PATCH 20/23] Suppress Rule 8.9 --- source/FreeRTOS_TCP_IP.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/FreeRTOS_TCP_IP.c b/source/FreeRTOS_TCP_IP.c index 78a657e485..ebefc6ff65 100644 --- a/source/FreeRTOS_TCP_IP.c +++ b/source/FreeRTOS_TCP_IP.c @@ -65,9 +65,6 @@ #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. * 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 * 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; /* @@ -107,6 +107,7 @@ * * @param[in] pxSocket: The socket to be checked. */ + /* coverity [single_use] */ void vSocketCloseNextTime( FreeRTOS_Socket_t * pxSocket ) { if( ( xPreviousSocket != NULL ) && ( xPreviousSocket != pxSocket ) ) @@ -552,7 +553,7 @@ /* Map the buffer onto a ProtocolHeaders_t struct for easy access to the fields. */ /* 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] */ const ProtocolHeaders_t * pxProtocolHeaders = ( ( const ProtocolHeaders_t * ) &( 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. */ /* 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] */ pxIPHeader = ( ( const IPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] ) ); ulLocalIP = FreeRTOS_htonl( pxIPHeader->ulDestinationIPAddress ); @@ -810,7 +811,7 @@ BaseType_t xResult = pdFALSE; /* 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] */ const ListItem_t * pxEndTCP = ( ( const ListItem_t * ) &( xBoundTCPSocketsList.xListEnd ) ); From 464ff7b26d3bb2b8395e9f39153234e016888e5d Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Wed, 3 Aug 2022 13:18:20 -0700 Subject: [PATCH 21/23] Fix build error --- .../portable/BufferManagement/BufferAllocation_2.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index b3beb57b2a..bc2b12bfab 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -395,19 +395,19 @@ UBaseType_t uxGetMinimumFreeNetworkBuffers( void ) /*-----------------------------------------------------------*/ NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDescriptor_t * pxNetworkBuffer, - size_t xNewSizeBytes ) + size_t uxNewSizeBytes ) { size_t xOriginalLength; uint8_t * pucBuffer; - size_t uxSizeBytes = xNewSizeBytes; + size_t uxSizeBytes = uxNewSizeBytes; NetworkBufferDescriptor_t * pxNetworkBufferCopy = pxNetworkBuffer; xOriginalLength = pxNetworkBufferCopy->xDataLength + ipBUFFER_PADDING; - xSizeBytes = xSizeBytes + ipBUFFER_PADDING; + uxSizeBytes = uxSizeBytes + ipBUFFER_PADDING; - pucBuffer = pucGetNetworkBuffer( &( xSizeBytes ) ); + pucBuffer = pucGetNetworkBuffer( &( uxSizeBytes ) ); if( pucBuffer == NULL ) { @@ -416,11 +416,11 @@ NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDe } else { - pxNetworkBufferCopy->xDataLength = xSizeBytes; + pxNetworkBufferCopy->xDataLength = uxSizeBytes; - if( xSizeBytes > xOriginalLength ) + if( uxSizeBytes > xOriginalLength ) { - xSizeBytes = xOriginalLength; + uxSizeBytes = xOriginalLength; } ( void ) memcpy( pucBuffer - ipBUFFER_PADDING, pxNetworkBufferCopy->pucEthernetBuffer - ipBUFFER_PADDING, xNewSizeBytes ); From c945cde5b833b0925a85f94492d97814c9b47858 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Wed, 3 Aug 2022 13:23:47 -0700 Subject: [PATCH 22/23] fix build error --- source/portable/BufferManagement/BufferAllocation_2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index bc2b12bfab..0e037ec751 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -423,7 +423,9 @@ NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDe uxSizeBytes = xOriginalLength; } - ( void ) memcpy( pucBuffer - ipBUFFER_PADDING, pxNetworkBufferCopy->pucEthernetBuffer - ipBUFFER_PADDING, xNewSizeBytes ); + ( void ) memcpy( pucBuffer - ipBUFFER_PADDING, + pxNetworkBufferCopy->pucEthernetBuffer - ipBUFFER_PADDING, + uxSizeBytes ); vReleaseNetworkBuffer( pxNetworkBufferCopy->pucEthernetBuffer ); pxNetworkBufferCopy->pucEthernetBuffer = pucBuffer; } From 5ab12ef94ca742e6a9b2763a02840c9c6ea8471e Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Wed, 3 Aug 2022 14:01:33 -0700 Subject: [PATCH 23/23] Fix coverity supression bugs --- source/FreeRTOS_TCP_IP.c | 2 +- source/portable/BufferManagement/BufferAllocation_2.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/FreeRTOS_TCP_IP.c b/source/FreeRTOS_TCP_IP.c index ebefc6ff65..590d469fb5 100644 --- a/source/FreeRTOS_TCP_IP.c +++ b/source/FreeRTOS_TCP_IP.c @@ -107,7 +107,7 @@ * * @param[in] pxSocket: The socket to be checked. */ - /* coverity [single_use] */ + /* coverity[single_use] */ void vSocketCloseNextTime( FreeRTOS_Socket_t * pxSocket ) { if( ( xPreviousSocket != NULL ) && ( xPreviousSocket != pxSocket ) ) diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index 0e037ec751..fd36eae484 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -395,11 +395,11 @@ UBaseType_t uxGetMinimumFreeNetworkBuffers( void ) /*-----------------------------------------------------------*/ NetworkBufferDescriptor_t * pxResizeNetworkBufferWithDescriptor( NetworkBufferDescriptor_t * pxNetworkBuffer, - size_t uxNewSizeBytes ) + size_t xNewSizeBytes ) { size_t xOriginalLength; uint8_t * pucBuffer; - size_t uxSizeBytes = uxNewSizeBytes; + size_t uxSizeBytes = xNewSizeBytes; NetworkBufferDescriptor_t * pxNetworkBufferCopy = pxNetworkBuffer;