whitecatboard / Lua-RTOS-ESP32

Lua RTOS for ESP32
Other
1.19k stars 221 forks source link

spi_eth.c throws compiler warnings #38

Closed jcwren closed 7 years ago

jcwren commented 7 years ago

(I'd submit a patch, but I have next to zero git skills, unless messing up a repository is a skill...)

Adding a ip_addr_t *dns_p = &dns; and passing dns_p instead of &dns to ip_addr_set_ip4_u32() fixes two of the warnings.

CC drivers/spi_eth.o
In file included from /Users/jcw/Projects/esp-idf/components/tcpip_adapter/include/tcpip_adapter.h:47:0,
                 from /Users/jcw/Projects/esp-idf/components/esp32/include/esp_event.h:23,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:37:
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c: In function 'spi_eth_setup':
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:88:23: warning: the address of 'dns' will always evaluate as 'true' [-Waddress]
   ip_addr_set_ip4_u32(&dns, dns1);
                       ^
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:95:49: note: in definition of macro 'ip_addr_set_ip4_u32'
 #define ip_addr_set_ip4_u32(ipaddr, val)  do{if(ipaddr){ip4_addr_set_u32(ip_2_ip4(ipaddr), val); \
                                                 ^
In file included from /Users/jcw/Projects/esp-idf/components/tcpip_adapter/include/tcpip_adapter.h:47:0,
                 from /Users/jcw/Projects/esp-idf/components/esp32/include/esp_event.h:23,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:37:
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:73:58: warning: the comparison will always evaluate as 'true' for the address of 'dns' will never be NULL [-Waddress]
 #define IP_SET_TYPE(ipaddr, iptype)     do { if((ipaddr) != NULL) { IP_SET_TYPE_VAL(*(ipaddr), iptype); }}while(0)
                                                          ^
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:96:3: note: in expansion of macro 'IP_SET_TYPE'
   IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0)
   ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:88:3: note: in expansion of macro 'ip_addr_set_ip4_u32'
   ip_addr_set_ip4_u32(&dns, dns1);
   ^
In file included from /Users/jcw/Projects/esp-idf/components/tcpip_adapter/include/tcpip_adapter.h:47:0,
                 from /Users/jcw/Projects/esp-idf/components/esp32/include/esp_event.h:23,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:37:
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:94:23: warning: the address of 'dns' will always evaluate as 'true' [-Waddress]
   ip_addr_set_ip4_u32(&dns, dns2);
                       ^
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:95:49: note: in definition of macro 'ip_addr_set_ip4_u32'
 #define ip_addr_set_ip4_u32(ipaddr, val)  do{if(ipaddr){ip4_addr_set_u32(ip_2_ip4(ipaddr), val); \
                                                 ^
In file included from /Users/jcw/Projects/esp-idf/components/tcpip_adapter/include/tcpip_adapter.h:47:0,
                 from /Users/jcw/Projects/esp-idf/components/esp32/include/esp_event.h:23,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:37:
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:73:58: warning: the comparison will always evaluate as 'true' for the address of 'dns' will never be NULL [-Waddress]
 #define IP_SET_TYPE(ipaddr, iptype)     do { if((ipaddr) != NULL) { IP_SET_TYPE_VAL(*(ipaddr), iptype); }}while(0)
                                                          ^
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:96:3: note: in expansion of macro 'IP_SET_TYPE'
   IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0)
   ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:94:3: note: in expansion of macro 'ip_addr_set_ip4_u32'
   ip_addr_set_ip4_u32(&dns, dns2);
   ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c: In function 'spi_eth_stop':
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:130:18: warning: unused variable 'error' [-Wunused-variable]
  driver_error_t *error;
                  ^
jolivepetrus commented 7 years ago

This is solved in https://github.com/whitecatboard/Lua-RTOS-ESP32/commit/dabb4c8c2f4f0374668044a5a31a3f2889cc75d0. Thanks for the pull request.