Skip to content

Commit 2fc09cf

Browse files
author
Holden
committed
cleanup some macro usages
1 parent e0db98d commit 2fc09cf

File tree

8 files changed

+24
-48
lines changed

8 files changed

+24
-48
lines changed

source/FreeRTOS_DNS_Parser.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,11 @@
489489

490490
/* If this is not a reply to our DNS request, it might be an mDNS or an LLMNR
491491
* request. Ask the application if it uses the name. */
492-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
492+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
493493
lDNSHookReturn = xApplicationDNSQueryHook( xSet.pcName );
494494
#else
495495
lDNSHookReturn = xApplicationDNSQueryHook_Multi( &xEndPoint, xSet.pcName );
496-
#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
496+
#endif /* if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
497497

498498
if( lDNSHookReturn )
499499
{
@@ -1149,11 +1149,11 @@
11491149
}
11501150
#endif
11511151

1152-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
1152+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
11531153
if( xApplicationDNSQueryHook( ( const char * ) ucNBNSName ) != pdFALSE )
11541154
#else
11551155
if( xApplicationDNSQueryHook_Multi( &( xEndPoint ), ( const char * ) ucNBNSName ) != pdFALSE )
1156-
#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
1156+
#endif /* if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
11571157
{
11581158
/* The field xDataLength was set to the total length of the UDP packet,
11591159
* i.e. the payload size plus sizeof( UDPPacket_t ). */

source/FreeRTOS_IP.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ void vIPNetworkUpCalls( NetworkEndPoint_t * pxEndPoint )
617617
pxEndPoint->bits.bEndPointUp = pdTRUE_UNSIGNED;
618618

619619
#if ( ipconfigUSE_NETWORK_EVENT_HOOK == 1 )
620-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
620+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
621621
{
622622
vApplicationIPNetworkEventHook( eNetworkUp );
623623
}
@@ -774,7 +774,7 @@ BaseType_t FreeRTOS_NetworkDownFromISR( struct xNetworkInterface * pxNetworkInte
774774
}
775775
/*-----------------------------------------------------------*/
776776

777-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
777+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
778778

779779
/**
780780
* @brief Obtain a buffer big enough for a UDP payload of given size.
@@ -795,7 +795,7 @@ BaseType_t FreeRTOS_NetworkDownFromISR( struct xNetworkInterface * pxNetworkInte
795795
{
796796
return FreeRTOS_GetUDPPayloadBuffer_Multi( uxRequestedSizeBytes, uxBlockTimeTicks, ipTYPE_IPv4 );
797797
}
798-
#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
798+
#endif /* if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
799799
/*-----------------------------------------------------------*/
800800

801801
/**
@@ -881,7 +881,7 @@ void * FreeRTOS_GetUDPPayloadBuffer_Multi( size_t uxRequestedSizeBytes,
881881
* As that bug has been repaired, there is not an urgent reason to warn.
882882
* It is better though to use the advised priority scheme. */
883883

884-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
884+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
885885

886886
/* Provide backward-compatibility with the earlier FreeRTOS+TCP which only had
887887
* single network interface. */
@@ -905,7 +905,7 @@ void * FreeRTOS_GetUDPPayloadBuffer_Multi( size_t uxRequestedSizeBytes,
905905
#endif /* ipconfigUSE_DHCP */
906906
return FreeRTOS_IPInit_Multi();
907907
}
908-
#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
908+
#endif /* if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
909909
/*-----------------------------------------------------------*/
910910

911911
/**
@@ -1081,7 +1081,7 @@ void FreeRTOS_GetEndPointConfiguration( uint32_t * pulIPAddress,
10811081
}
10821082
/*-----------------------------------------------------------*/
10831083

1084-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
1084+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
10851085

10861086
/**
10871087
* @brief Get the current IPv4 address configuration of the first endpoint.
@@ -1106,7 +1106,7 @@ void FreeRTOS_GetEndPointConfiguration( uint32_t * pulIPAddress,
11061106
FreeRTOS_GetEndPointConfiguration( pulIPAddress, pulNetMask,
11071107
pulGatewayAddress, pulDNSServerAddress, pxEndPoint );
11081108
}
1109-
#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
1109+
#endif /* if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
11101110
/*-----------------------------------------------------------*/
11111111

11121112
/**
@@ -1152,7 +1152,7 @@ void FreeRTOS_SetEndPointConfiguration( const uint32_t * pulIPAddress,
11521152
}
11531153
/*-----------------------------------------------------------*/
11541154

1155-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
1155+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
11561156

11571157
/**
11581158
* @brief Set the current IPv4 network address configuration. Only non-NULL
@@ -1177,7 +1177,7 @@ void FreeRTOS_SetEndPointConfiguration( const uint32_t * pulIPAddress,
11771177
FreeRTOS_SetEndPointConfiguration( pulIPAddress, pulNetMask,
11781178
pulGatewayAddress, pulDNSServerAddress, pxEndPoint );
11791179
}
1180-
#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
1180+
#endif /* if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
11811181
/*-----------------------------------------------------------*/
11821182

11831183
#if ( ipconfigUSE_TCP == 1 )

source/FreeRTOS_TCP_Transmission_IPV4.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
#include "NetworkInterface.h"
5454
#include "NetworkBufferManagement.h"
5555
#include "FreeRTOS_ARP.h"
56-
#include "FreeRTOSIPConfigDefaults.h"
5756

5857
#include "FreeRTOS_TCP_IP.h"
5958
#include "FreeRTOS_TCP_Reception.h"

source/FreeRTOS_TCP_Transmission_IPV6.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
#include "NetworkInterface.h"
5454
#include "NetworkBufferManagement.h"
5555
#include "FreeRTOS_ARP.h"
56-
#include "FreeRTOSIPConfigDefaults.h"
5756
#include "FreeRTOS_ND.h"
5857

5958
#include "FreeRTOS_TCP_IP.h"

source/include/FreeRTOS_DHCP.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@
3939
/* Application level configuration options. */
4040
#include "FreeRTOSIPConfig.h"
4141

42-
#if ( ipconfigUSE_DHCP != 0 ) && ( ipconfigNETWORK_MTU < 586U )
43-
44-
/* DHCP must be able to receive an options field of 312 bytes, the fixed
45-
* part of the DHCP packet is 240 bytes, and the IP/UDP headers take 28 bytes. */
46-
#error ipconfigNETWORK_MTU needs to be at least 586 to use DHCP
47-
#endif
48-
4942
/* Parameter widths in the DHCP packet. */
5043
#define dhcpCLIENT_HARDWARE_ADDRESS_LENGTH 16 /**< Client hardware address length.*/
5144
#define dhcpSERVER_HOST_NAME_LENGTH 64 /**< Server host name length. */

source/include/FreeRTOS_DNS_Globals.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@
5555
* name field is an offset to the string, rather than the string itself. */
5656
#define dnsNAME_IS_OFFSET ( ( uint8_t ) 0xc0 )
5757

58-
/** @brief The maximum number of times a DNS request should be sent out if a response
59-
* is not received, before giving up. */
60-
#ifndef ipconfigDNS_REQUEST_ATTEMPTS
61-
#define ipconfigDNS_REQUEST_ATTEMPTS 5
62-
#endif
63-
64-
6558
/* NBNS flags. */
6659
#if ( ipconfigUSE_NBNS == 1 )
6760
#define dnsNBNS_FLAGS_RESPONSE 0x8000U /**< NBNS response flag. */
@@ -304,7 +297,7 @@
304297
* The following function should be provided by the user and return true if it
305298
* matches the domain name.
306299
*/
307-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
300+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
308301
/* Even though the function is defined in main.c, the rule is violated. */
309302
/* misra_c_2012_rule_8_6_violation */
310303
extern BaseType_t xApplicationDNSQueryHook( const char * pcName );
@@ -313,7 +306,7 @@
313306
/* misra_c_2012_rule_8_6_violation */
314307
extern BaseType_t xApplicationDNSQueryHook_Multi( struct xNetworkEndPoint * pxEndPoint,
315308
const char * pcName );
316-
#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
309+
#endif /* ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
317310

318311
#endif /* ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_NBNS == 1 ) */
319312
#endif /* ipconfigUSE_DNS */

source/include/FreeRTOS_IP.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void );
304304

305305
struct xNetworkInterface;
306306

307-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
307+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
308308

309309
/* Do not call the following function directly. It is there for downward compatibility.
310310
* The function FreeRTOS_IPInit() will call it to initialise the interface and end-point
@@ -336,7 +336,7 @@ struct xNetworkInterface;
336336
void * FreeRTOS_GetUDPPayloadBuffer( size_t uxRequestedSizeBytes,
337337
TickType_t uxBlockTimeTicks );
338338

339-
#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
339+
#endif /* if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
340340

341341
/*
342342
* Returns the addresses stored in an end-point structure.
@@ -372,7 +372,7 @@ const uint8_t * FreeRTOS_GetMACAddress( void );
372372
void FreeRTOS_UpdateMACAddress( const uint8_t ucMACAddress[ ipMAC_ADDRESS_LENGTH_BYTES ] );
373373
#if ( ipconfigUSE_NETWORK_EVENT_HOOK == 1 )
374374
/* This function shall be defined by the application. */
375-
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
375+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
376376
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent );
377377
#else
378378
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
@@ -445,12 +445,6 @@ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber );
445445
* This pointer is for internal use only. */
446446
extern NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer;
447447

448-
/* For backward compatibility define old structure names to the newer equivalent
449-
* structure name. */
450-
#ifndef ipconfigENABLE_BACKWARD_COMPATIBILITY
451-
#define ipconfigENABLE_BACKWARD_COMPATIBILITY 1
452-
#endif
453-
454448
#if ( ipconfigENABLE_BACKWARD_COMPATIBILITY == 1 )
455449
#define xIPStackEvent_t IPStackEvent_t
456450
#define xNetworkBufferDescriptor_t NetworkBufferDescriptor_t

source/portable/BufferManagement/BufferAllocation_2.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,12 @@
6969
/* MISRA Ref 20.10.1 [Lack of sizeof operator and compile time error checking] */
7070
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2010 */
7171
/* coverity[misra_c_2012_rule_20_10_violation] */
72-
#if defined( ipconfigETHERNET_MINIMUM_PACKET_BYTES )
73-
#define ASSERT_CONCAT_( a, b ) a ## b
74-
#define ASSERT_CONCAT( a, b ) ASSERT_CONCAT_( a, b )
75-
#define STATIC_ASSERT( e ) \
76-
; enum { ASSERT_CONCAT( assert_line_, __LINE__ ) = 1 / ( !!( e ) ) }
77-
78-
STATIC_ASSERT( ipconfigETHERNET_MINIMUM_PACKET_BYTES <= baMINIMAL_BUFFER_SIZE );
79-
#endif
72+
#define ASSERT_CONCAT_( a, b ) a ## b
73+
#define ASSERT_CONCAT( a, b ) ASSERT_CONCAT_( a, b )
74+
#define STATIC_ASSERT( e ) \
75+
; enum { ASSERT_CONCAT( assert_line_, __LINE__ ) = 1 / ( !!( e ) ) }
76+
77+
STATIC_ASSERT( ipconfigETHERNET_MINIMUM_PACKET_BYTES <= baMINIMAL_BUFFER_SIZE );
8078

8179
/* A list of free (available) NetworkBufferDescriptor_t structures. */
8280
static List_t xFreeBuffersList;

0 commit comments

Comments
 (0)