Skip to content

Commit

Permalink
cleanup some macro usages
Browse files Browse the repository at this point in the history
  • Loading branch information
Holden committed Jun 19, 2023
1 parent e0db98d commit 2fc09cf
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 48 deletions.
8 changes: 4 additions & 4 deletions source/FreeRTOS_DNS_Parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,11 @@

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

if( lDNSHookReturn )
{
Expand Down Expand Up @@ -1149,11 +1149,11 @@
}
#endif

#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
if( xApplicationDNSQueryHook( ( const char * ) ucNBNSName ) != pdFALSE )
#else
if( xApplicationDNSQueryHook_Multi( &( xEndPoint ), ( const char * ) ucNBNSName ) != pdFALSE )
#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
#endif /* if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
{
/* The field xDataLength was set to the total length of the UDP packet,
* i.e. the payload size plus sizeof( UDPPacket_t ). */
Expand Down
18 changes: 9 additions & 9 deletions source/FreeRTOS_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ void vIPNetworkUpCalls( NetworkEndPoint_t * pxEndPoint )
pxEndPoint->bits.bEndPointUp = pdTRUE_UNSIGNED;

#if ( ipconfigUSE_NETWORK_EVENT_HOOK == 1 )
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
{
vApplicationIPNetworkEventHook( eNetworkUp );
}
Expand Down Expand Up @@ -774,7 +774,7 @@ BaseType_t FreeRTOS_NetworkDownFromISR( struct xNetworkInterface * pxNetworkInte
}
/*-----------------------------------------------------------*/

#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )

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

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

#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )

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

/**
Expand Down Expand Up @@ -1081,7 +1081,7 @@ void FreeRTOS_GetEndPointConfiguration( uint32_t * pulIPAddress,
}
/*-----------------------------------------------------------*/

#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )

/**
* @brief Get the current IPv4 address configuration of the first endpoint.
Expand All @@ -1106,7 +1106,7 @@ void FreeRTOS_GetEndPointConfiguration( uint32_t * pulIPAddress,
FreeRTOS_GetEndPointConfiguration( pulIPAddress, pulNetMask,
pulGatewayAddress, pulDNSServerAddress, pxEndPoint );
}
#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
#endif /* if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
/*-----------------------------------------------------------*/

/**
Expand Down Expand Up @@ -1152,7 +1152,7 @@ void FreeRTOS_SetEndPointConfiguration( const uint32_t * pulIPAddress,
}
/*-----------------------------------------------------------*/

#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )

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

#if ( ipconfigUSE_TCP == 1 )
Expand Down
1 change: 0 additions & 1 deletion source/FreeRTOS_TCP_Transmission_IPV4.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#include "NetworkInterface.h"
#include "NetworkBufferManagement.h"
#include "FreeRTOS_ARP.h"
#include "FreeRTOSIPConfigDefaults.h"

#include "FreeRTOS_TCP_IP.h"
#include "FreeRTOS_TCP_Reception.h"
Expand Down
1 change: 0 additions & 1 deletion source/FreeRTOS_TCP_Transmission_IPV6.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#include "NetworkInterface.h"
#include "NetworkBufferManagement.h"
#include "FreeRTOS_ARP.h"
#include "FreeRTOSIPConfigDefaults.h"
#include "FreeRTOS_ND.h"

#include "FreeRTOS_TCP_IP.h"
Expand Down
7 changes: 0 additions & 7 deletions source/include/FreeRTOS_DHCP.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@
/* Application level configuration options. */
#include "FreeRTOSIPConfig.h"

#if ( ipconfigUSE_DHCP != 0 ) && ( ipconfigNETWORK_MTU < 586U )

/* DHCP must be able to receive an options field of 312 bytes, the fixed
* part of the DHCP packet is 240 bytes, and the IP/UDP headers take 28 bytes. */
#error ipconfigNETWORK_MTU needs to be at least 586 to use DHCP
#endif

/* Parameter widths in the DHCP packet. */
#define dhcpCLIENT_HARDWARE_ADDRESS_LENGTH 16 /**< Client hardware address length.*/
#define dhcpSERVER_HOST_NAME_LENGTH 64 /**< Server host name length. */
Expand Down
11 changes: 2 additions & 9 deletions source/include/FreeRTOS_DNS_Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@
* name field is an offset to the string, rather than the string itself. */
#define dnsNAME_IS_OFFSET ( ( uint8_t ) 0xc0 )

/** @brief The maximum number of times a DNS request should be sent out if a response
* is not received, before giving up. */
#ifndef ipconfigDNS_REQUEST_ATTEMPTS
#define ipconfigDNS_REQUEST_ATTEMPTS 5
#endif


/* NBNS flags. */
#if ( ipconfigUSE_NBNS == 1 )
#define dnsNBNS_FLAGS_RESPONSE 0x8000U /**< NBNS response flag. */
Expand Down Expand Up @@ -304,7 +297,7 @@
* The following function should be provided by the user and return true if it
* matches the domain name.
*/
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
/* Even though the function is defined in main.c, the rule is violated. */
/* misra_c_2012_rule_8_6_violation */
extern BaseType_t xApplicationDNSQueryHook( const char * pcName );
Expand All @@ -313,7 +306,7 @@
/* misra_c_2012_rule_8_6_violation */
extern BaseType_t xApplicationDNSQueryHook_Multi( struct xNetworkEndPoint * pxEndPoint,
const char * pcName );
#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
#endif /* ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */

#endif /* ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_NBNS == 1 ) */
#endif /* ipconfigUSE_DNS */
Expand Down
12 changes: 3 additions & 9 deletions source/include/FreeRTOS_IP.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void );

struct xNetworkInterface;

#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )

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

#endif /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
#endif /* if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */

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

/* For backward compatibility define old structure names to the newer equivalent
* structure name. */
#ifndef ipconfigENABLE_BACKWARD_COMPATIBILITY
#define ipconfigENABLE_BACKWARD_COMPATIBILITY 1
#endif

#if ( ipconfigENABLE_BACKWARD_COMPATIBILITY == 1 )
#define xIPStackEvent_t IPStackEvent_t
#define xNetworkBufferDescriptor_t NetworkBufferDescriptor_t
Expand Down
14 changes: 6 additions & 8 deletions source/portable/BufferManagement/BufferAllocation_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@
/* MISRA Ref 20.10.1 [Lack of sizeof operator and compile time error checking] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2010 */
/* coverity[misra_c_2012_rule_20_10_violation] */
#if defined( ipconfigETHERNET_MINIMUM_PACKET_BYTES )
#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 ) ) }

STATIC_ASSERT( ipconfigETHERNET_MINIMUM_PACKET_BYTES <= baMINIMAL_BUFFER_SIZE );
#endif
#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 ) ) }

STATIC_ASSERT( ipconfigETHERNET_MINIMUM_PACKET_BYTES <= baMINIMAL_BUFFER_SIZE );

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

0 comments on commit 2fc09cf

Please sign in to comment.