From 89d825f6032fed496e124b53cfcb371d331d9b14 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 5 May 2017 16:02:44 +0800 Subject: [PATCH] netif: Fix IPv6-only build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix below build error if LWIP_IPV4 == 0. cc -g -Wall -DLWIP_DEBUG -pedantic -Werror -Wparentheses -Wsequence-point -Wswitch-default -Wextra -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wc++-compat -Wwrite-strings -Wold-style-definition -Wcast-align -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wno-address -Wunreachable-code -Wuninitialized -Wlogical-op -I. -I../../.. -I../../../../lwip/src/include -I../../../ports/unix/port/include -I../../../../mbedtls/include -Wno-redundant-decls -DLWIP_HAVE_MBEDTLS=1 -c ../../../../lwip/src/core/netif.c ../../../../lwip/src/core/netif.c: In function ‘netif_add’: ../../../../lwip/src/core/netif.c:284:7: error: ‘ipaddr’ undeclared (first use in this function) if (ipaddr == NULL) { ^~~~~~ ../../../../lwip/src/core/netif.c:284:7: note: each undeclared identifier is reported only once for each function it appears in ../../../../lwip/src/core/netif.c:285:14: error: implicit declaration of function ‘ip_2_ip4’ [-Werror=implicit-function-declaration] ipaddr = ip_2_ip4(IP4_ADDR_ANY); ^~~~~~~~ ../../../../lwip/src/core/netif.c:285:5: error: nested extern declaration of ‘ip_2_ip4’ [-Werror=nested-externs] ipaddr = ip_2_ip4(IP4_ADDR_ANY); ^~~~~~ ../../../../lwip/src/core/netif.c:285:23: error: ‘IP4_ADDR_ANY’ undeclared (first use in this function) ipaddr = ip_2_ip4(IP4_ADDR_ANY); ^~~~~~~~~~~~ ../../../../lwip/src/core/netif.c:287:7: error: ‘netmask’ undeclared (first use in this function) if (netmask == NULL) { ^~~~~~~ ../../../../lwip/src/core/netif.c:290:7: error: ‘gw’ undeclared (first use in this function) if (gw == NULL) { ^~ cc1: all warnings being treated as errors ../../Common.allports.mk:94: recipe for target 'netif.o' failed make: *** [netif.o] Error 1 Fixes: 5967380c2034 ("netif_add: avoid passing NULL pointers to subsequent functions") Signed-off-by: Axel Lin Signed-off-by: Dirk Ziegelmeier --- src/core/netif.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/netif.c b/src/core/netif.c index 994bc4fd..ddedb4cc 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -281,6 +281,7 @@ netif_add(struct netif *netif, LWIP_ASSERT("No init function given", init != NULL); +#if LWIP_IPV4 if (ipaddr == NULL) { ipaddr = ip_2_ip4(IP4_ADDR_ANY); } @@ -290,6 +291,7 @@ netif_add(struct netif *netif, if (gw == NULL) { gw = ip_2_ip4(IP4_ADDR_ANY); } +#endif /* LWIP_IPV4 */ /* reset new interface configuration state */ #if LWIP_IPV4