From ba270c2414142c5474349c32338d04921bbc6892 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 15 Dec 2017 14:47:52 +0800 Subject: [PATCH] apps/sntp: Use ip_addr_copy to save server address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use ip_addr_copy instead of ip_addr_set to avoid NULL test for &sntp_last_server_address. This fixes build warning when SNTP_CHECK_RESPONSE>=1 && LWIP_IPV4=1 && LWIP_IPV6=1. In file included from ../../../../lwip/src/include/lwip/apps/sntp.h:41:0, from ../../../../lwip/src/apps/sntp/sntp.c:52: ../../../../lwip/src/apps/sntp/sntp.c: In function ‘sntp_send_request’: ../../../../lwip/src/include/lwip/ip_addr.h:105:58: error: the comparison will always evaluate as ‘true’ for the address of ‘sntp_last_server_address’ will never be NULL [-Werror=address] #define IP_SET_TYPE(ipaddr, iptype) do { if((ipaddr) != NULL) { IP_SET_TYPE_VAL(*(ipaddr), iptype); }}while(0) ^ ../../../../lwip/src/include/lwip/ip_addr.h:157:36: note: in expansion of macro ‘IP_SET_TYPE’ #define ip_addr_set(dest, src) do{ IP_SET_TYPE(dest, IP_GET_TYPE(src)); if(IP_IS_V6(src)){ \ ^~~~~~~~~~~ ../../../../lwip/src/apps/sntp/sntp.c:549:5: note: in expansion of macro ‘ip_addr_set’ ip_addr_set(&sntp_last_server_address, server_addr); ^~~~~~~~~~~ Signed-off-by: Axel Lin Signed-off-by: goldsimon --- src/apps/sntp/sntp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/sntp/sntp.c b/src/apps/sntp/sntp.c index 1bb741e8..8ae2ec65 100644 --- a/src/apps/sntp/sntp.c +++ b/src/apps/sntp/sntp.c @@ -546,7 +546,7 @@ sntp_send_request(const ip_addr_t *server_addr) sys_timeout((u32_t)SNTP_RECV_TIMEOUT, sntp_try_next_server, NULL); #if SNTP_CHECK_RESPONSE >= 1 /* save server address to verify it in sntp_recv */ - ip_addr_set(&sntp_last_server_address, server_addr); + ip_addr_copy(sntp_last_server_address, *server_addr); #endif /* SNTP_CHECK_RESPONSE >= 1 */ } else { LWIP_DEBUGF(SNTP_DEBUG_SERIOUS, ("sntp_send_request: Out of memory, trying again in %"U32_F" ms\n",