diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e4ee7e8d..ec0a264f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,11 +161,6 @@ else() endif() endif() -######################################################################## -# Requirements -set(CMAKE_C_STANDARD 90) # Note FreeRTOS-Kernel uses C99 constructs. -set(CMAKE_C_STANDARD_REQUIRED ON) - ######################################################################## # Overall Compile Options # Note the compile option strategy is to error on everything and then @@ -195,9 +190,9 @@ add_compile_options( $<$:-Wall> $<$:-Wextra> - $<$:-Wpedantic> $<$:-Werror> $<$:-Weverything> + $<$:-Wpedantic> # TODO: Add in other Compilers here. ) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index a990fe947..bff59a3f4 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,5 +1,7 @@ add_library( freertos_plus_tcp STATIC ) +set_property(TARGET freertos_plus_tcp PROPERTY C_STANDARD 90) + target_sources( freertos_plus_tcp PRIVATE include/FreeRTOS_ARP.h @@ -74,10 +76,7 @@ target_compile_options( freertos_plus_tcp $<$:-Wno-shorten-64-to-32> $<$:-Wno-sign-conversion> $<$:-Wno-unused-macros> - $<$:-Wno-unused-but-set-variable> - $<$:-Wno-unused-parameter> - $<$:-Wno-unused-variable> - $<$:-Wno-pedantic> + $<$:-Wno-unused-parameter> ) target_link_libraries( freertos_plus_tcp diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index df777be9a..a77e7f4fb 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1002,10 +1002,10 @@ void FreeRTOS_ReleaseUDPPayloadBuffer( void const * pvBuffer ) static uint16_t usSequenceNumber = 0; uint8_t * pucChar; size_t uxTotalLength; + BaseType_t xEnoughSpace; IPStackEvent_t xStackTxEvent = { eStackTxEvent, NULL }; uxTotalLength = uxNumberOfBytesToSend + sizeof( ICMPPacket_t ); - BaseType_t xEnoughSpace; if( uxNumberOfBytesToSend < ( ipconfigNETWORK_MTU - ( sizeof( IPHeader_t ) + sizeof( ICMPHeader_t ) ) ) ) { diff --git a/source/FreeRTOS_TCP_IP.c b/source/FreeRTOS_TCP_IP.c index 995173573..f586a15b6 100644 --- a/source/FreeRTOS_TCP_IP.c +++ b/source/FreeRTOS_TCP_IP.c @@ -634,28 +634,36 @@ /* Function might modify the parameter. */ NetworkBufferDescriptor_t * pxNetworkBuffer = pxDescriptor; - configASSERT( pxNetworkBuffer != NULL ); - configASSERT( pxNetworkBuffer->pucEthernetBuffer != NULL ); - /* 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 */ - /* coverity[misra_c_2012_rule_11_3_violation] */ - const ProtocolHeaders_t * pxProtocolHeaders = ( ( const ProtocolHeaders_t * ) - &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + xIPHeaderSize( pxNetworkBuffer ) ] ) ); + ProtocolHeaders_t * pxProtocolHeaders; FreeRTOS_Socket_t * pxSocket; - uint16_t ucTCPFlags = pxProtocolHeaders->xTCPHeader.ucTCPFlags; + uint16_t ucTCPFlags; uint32_t ulLocalIP; - uint16_t usLocalPort = FreeRTOS_htons( pxProtocolHeaders->xTCPHeader.usDestinationPort ); - uint16_t usRemotePort = FreeRTOS_htons( pxProtocolHeaders->xTCPHeader.usSourcePort ); + uint16_t usLocalPort; + uint16_t usRemotePort; uint32_t ulRemoteIP; - uint32_t ulSequenceNumber = FreeRTOS_ntohl( pxProtocolHeaders->xTCPHeader.ulSequenceNumber ); - uint32_t ulAckNumber = FreeRTOS_ntohl( pxProtocolHeaders->xTCPHeader.ulAckNr ); + uint32_t ulSequenceNumber; + uint32_t ulAckNumber; BaseType_t xResult = pdPASS; const IPHeader_t * pxIPHeader; + configASSERT( pxNetworkBuffer != NULL ); + configASSERT( pxNetworkBuffer->pucEthernetBuffer != NULL ); + + /* 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] */ + pxProtocolHeaders = ( ( ProtocolHeaders_t * ) + &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + xIPHeaderSize( pxNetworkBuffer ) ] ) ); + + ucTCPFlags = pxProtocolHeaders->xTCPHeader.ucTCPFlags; + usLocalPort = FreeRTOS_htons( pxProtocolHeaders->xTCPHeader.usDestinationPort ); + usRemotePort = FreeRTOS_htons( pxProtocolHeaders->xTCPHeader.usSourcePort ); + ulSequenceNumber = FreeRTOS_ntohl( pxProtocolHeaders->xTCPHeader.ulSequenceNumber ); + ulAckNumber = FreeRTOS_ntohl( pxProtocolHeaders->xTCPHeader.ulAckNr ); + /* Check for a minimum packet size. */ if( pxNetworkBuffer->xDataLength < ( ipSIZE_OF_ETH_HEADER + xIPHeaderSize( pxNetworkBuffer ) + ipSIZE_OF_TCP_HEADER ) ) { diff --git a/source/FreeRTOS_UDP_IP.c b/source/FreeRTOS_UDP_IP.c index b5249e430..43865d9e6 100644 --- a/source/FreeRTOS_UDP_IP.c +++ b/source/FreeRTOS_UDP_IP.c @@ -310,6 +310,7 @@ BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t * pxNetworkBuffe { BaseType_t xReturn = pdPASS; FreeRTOS_Socket_t * pxSocket; + const UDPPacket_t * pxUDPPacket; configASSERT( pxNetworkBuffer != NULL ); configASSERT( pxNetworkBuffer->pucEthernetBuffer != NULL ); @@ -319,7 +320,7 @@ BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t * pxNetworkBuffe /* 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] */ - const UDPPacket_t * pxUDPPacket = ( ( const UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + pxUDPPacket = ( ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); /* Caller must check for minimum packet size. */ pxSocket = pxUDPSocketLookup( usPort ); diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index c3baacc3d..e82fffaf8 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -73,11 +73,10 @@ #define ASSERT_CONCAT_( a, b ) a ## b #define ASSERT_CONCAT( a, b ) ASSERT_CONCAT_( a, b ) #define STATIC_ASSERT( e ) \ - ; enum { ASSERT_CONCAT( assert_line_, __LINE__ ) = 1 / ( !!( e ) ) } + enum { ASSERT_CONCAT( assert_line_, __LINE__ ) = 1 / ( !!( e ) ) } STATIC_ASSERT( ipconfigETHERNET_MINIMUM_PACKET_BYTES <= baMINIMAL_BUFFER_SIZE ); #endif - /* A list of free (available) NetworkBufferDescriptor_t structures. */ static List_t xFreeBuffersList; diff --git a/test/build-combination/Common/FreeRTOSConfig.h b/test/build-combination/Common/FreeRTOSConfig.h index a7f7d86ba..30fea81c6 100644 --- a/test/build-combination/Common/FreeRTOSConfig.h +++ b/test/build-combination/Common/FreeRTOSConfig.h @@ -116,13 +116,18 @@ /* The function that implements FreeRTOS printf style output, and the macro * that maps the configPRINTF() macros to that function. */ -#define configPRINTF( X ) +void vLoggingPrintf( char const * pcFormat, + ... ); + +/* The function that implements FreeRTOS printf style output, and the macro + * that maps the configPRINTF() macros to that function. */ +#define configPRINTF( X ) vLoggingPrintf X /* Non-format version thread-safe print. */ -#define configPRINT( X ) +#define configPRINT( X ) vLoggingPrintf X /* Non-format version thread-safe print. */ -#define configPRINT_STRING( X ) +#define configPRINT_STRING( X ) vLoggingPrintf X /* Application specific definitions follow. **********************************/