lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] [PATCH] ip_addr.h: Add cast in IP_SET_TYPE() macro in o


From: address@hidden
Subject: Re: [lwip-devel] [PATCH] ip_addr.h: Add cast in IP_SET_TYPE() macro in order to fix compiler warnings/errors
Date: Tue, 1 Jan 2019 19:42:15 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3

Am 01.01.2019 um 19:38 schrieb Jacob Kroon:
Fix building unit tests (contrib/ports/unix/check) on Debian 9, gcc 6.3.0.

Fixes:
<snip>/ip_addr.h:105:58: error: the comparison will always evaluate as ‘true’ 
for the address of ‘ip1’ will never be NULL [-Werror=address]
  #define IP_SET_TYPE(ipaddr, iptype)     do { if((ipaddr) != NULL) { 
IP_SET_TYPE_VAL(*(ipaddr),iptype); }}while(0)

Signed-off-by: Jacob Kroon <address@hidden>

In contrast to other open source projects, we don't use this mailing list to send raw patches. We use the bugtracker at savannah instead.

---
  src/include/lwip/ip_addr.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/include/lwip/ip_addr.h b/src/include/lwip/ip_addr.h
index ee7a0c9d..aed7fbcf 100644
--- a/src/include/lwip/ip_addr.h
+++ b/src/include/lwip/ip_addr.h
@@ -102,7 +102,7 @@ extern const ip_addr_t ip_addr_any_type;
  #define IP_IS_V6(ipaddr)              (((ipaddr) != NULL) && 
IP_IS_V6_VAL(*(ipaddr)))
#define IP_SET_TYPE_VAL(ipaddr, iptype) do { (ipaddr).type = (iptype); }while(0)
-#define IP_SET_TYPE(ipaddr, iptype)     do { if((ipaddr) != NULL) { 
IP_SET_TYPE_VAL(*(ipaddr), iptype); }}while(0)
+#define IP_SET_TYPE(ipaddr, iptype)     do { if((void*)(ipaddr) != NULL) { 
IP_SET_TYPE_VAL(*(ipaddr), iptype); }}while(0)

This change silences all those warnings. Instead, we want to use IP_SET_TYPE_VAL() for the callers where this warning appears.

Regards,
Simon

  #define IP_GET_TYPE(ipaddr)           ((ipaddr)->type)
#define IP_ADDR_RAW_SIZE(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_V4 ? sizeof(ip4_addr_t) : sizeof(ip6_addr_t))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]