Skip to content

Commit 0e53ff3

Browse files
committed
Fix compilation error if DNS features are disabled
The code would fail to compile unless one of ipconfigUSE_DNS_CACHE, ipconfigUSE_MDNS, ipconfigUSE_LLMNR, and ipconfigDNS_USE_CALLBACKS were set.
1 parent 3733583 commit 0e53ff3

File tree

3 files changed

+348
-3
lines changed

3 files changed

+348
-3
lines changed

source/FreeRTOS_DNS_Parser.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,11 @@
637637
const DNSAnswerRecord_t * pxDNSAnswerRecord;
638638
IPv46_Address_t xIP_Address;
639639

640+
#if ( ipconfigUSE_DNS_CALLBACKS == 1 )
640641
struct freertos_addrinfo * pxNewAddress = NULL;
642+
#else
643+
(void)ppxAddressInfo;
644+
#endif
641645

642646
for( x = 0U; x < pxSet->usAnswers; x++ )
643647
{
@@ -737,10 +741,12 @@
737741
&( pxSet->pucByte[ sizeof( DNSAnswerRecord_t ) ] ),
738742
ipSIZE_OF_IPv6_ADDRESS );
739743

744+
#if ( ipconfigUSE_DNS_CALLBACKS == 1 )
740745
if( ppxAddressInfo != NULL )
741746
{
742747
pxNewAddress = pxNew_AddrInfo( pxSet->pcName, FREERTOS_AF_INET6, xIP_Address.xIPAddress.xIP_IPv6.ucBytes );
743748
}
749+
#endif
744750

745751
xIP_Address.xIs_IPv6 = pdTRUE;
746752

@@ -765,17 +771,20 @@
765771
pvCopyDest = &( pxSet->ulIPAddress );
766772
( void ) memcpy( pvCopyDest, pvCopySource, pxSet->uxAddressLength );
767773

774+
#if ( ipconfigUSE_DNS_CALLBACKS == 1 )
768775
if( ppxAddressInfo != NULL )
769776
{
770777
const uint8_t * ucBytes = ( uint8_t * ) &( pxSet->ulIPAddress );
771778

772779
pxNewAddress = pxNew_AddrInfo( pxSet->pcName, FREERTOS_AF_INET4, ucBytes );
773780
}
781+
#endif
774782

775783
xIP_Address.xIPAddress.ulIP_IPv4 = pxSet->ulIPAddress;
776784
xIP_Address.xIs_IPv6 = pdFALSE;
777785
}
778786

787+
#if ( ipconfigUSE_DNS_CALLBACKS == 1 )
779788
if( pxNewAddress != NULL )
780789
{
781790
if( *( ppxAddressInfo ) == NULL )
@@ -790,10 +799,7 @@
790799
}
791800

792801
pxSet->ppxLastAddress = &( pxNewAddress->ai_next );
793-
}
794802

795-
#if ( ipconfigDNS_USE_CALLBACKS == 1 )
796-
{
797803
BaseType_t xCallbackResult;
798804

799805
xCallbackResult = xDNSDoCallback( pxSet, ( ppxAddressInfo != NULL ) ? *( ppxAddressInfo ) : NULL );

test/build-combination/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST
88
ENABLE_ALL_IPV4_TCP # Enable all configuration settings IPv4 TCP
99
ENABLE_ALL_IPV6_TCP # Enable all configuration settings IPv6 TCP
1010
ENABLE_ALL_IPV4_IPV6 # Enable all configuration settings IPv4 IPv6 UDP
11+
DISABLE_DNS_FEATURES # Enable all except DNS caching, callbacks, mDNS
1112
DISABLE_ALL # Disable all configuration settings
1213
HEADER_SELF_CONTAIN # Enable header self contain test
1314
DEFAULT_CONF # Default (typical) configuration
@@ -59,6 +60,11 @@ add_library( freertos_plus_tcp_config_all_enable_ipv6_tcp INTERFACE)
5960
target_include_directories(freertos_plus_tcp_config_all_enable_ipv6_tcp INTERFACE Enable_IPv6_TCP)
6061
target_link_libraries(freertos_plus_tcp_config_all_enable_ipv6_tcp INTERFACE freertos_plus_tcp_config_common)
6162

63+
# -------------------------------------------------------------------
64+
add_library( freertos_plus_tcp_config_disable_dns_features INTERFACE)
65+
target_include_directories(freertos_plus_tcp_config_disable_dns_features INTERFACE DisableDnsFeatures)
66+
target_link_libraries(freertos_plus_tcp_config_disable_dns_features INTERFACE freertos_plus_tcp_config_common)
67+
6268
# -------------------------------------------------------------------
6369
add_library( freertos_plus_tcp_config_header_self_contain INTERFACE)
6470
target_include_directories(freertos_plus_tcp_config_header_self_contain INTERFACE Header_Self_Contain)
@@ -90,6 +96,8 @@ elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "ENABLE_ALL_IPV6_TCP" )
9096
add_library( freertos_config ALIAS freertos_plus_tcp_config_all_enable_ipv6_tcp)
9197
elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "ENABLE_ALL_IPV4_IPV6" )
9298
add_library( freertos_config ALIAS freertos_plus_tcp_config_all_enable_ipv4_ipv6)
99+
elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "DISABLE_DNS_FEATURES" )
100+
add_library( freertos_config ALIAS freertos_plus_tcp_config_disable_dns_features)
93101
elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "HEADER_SELF_CONTAIN" )
94102
add_library( freertos_config ALIAS freertos_plus_tcp_config_header_self_contain)
95103
include( Header_Self_Contain/headerSelfContain.cmake )

0 commit comments

Comments
 (0)