From 60d90dee90fb73f6ba33be3f82453fe49718de45 Mon Sep 17 00:00:00 2001 From: Zhang Jun Hao Date: Wed, 2 May 2018 21:27:17 +0800 Subject: [PATCH] feat(lwip): Fix compile warning in lwip --- components/lwip/apps/dhcpserver/dhcpserver.c | 17 +++--- components/lwip/apps/sntp/sntp_time.c | 58 ------------------- components/lwip/apps/sntp/time.c | 3 + components/lwip/component.mk | 2 +- .../include/lwip/apps/dhcpserver/dhcpserver.h | 15 ----- components/lwip/include/lwip/port/lwipopts.h | 12 ++++ components/lwip/port/freertos/sys_arch.c | 2 +- 7 files changed, 24 insertions(+), 85 deletions(-) diff --git a/components/lwip/apps/dhcpserver/dhcpserver.c b/components/lwip/apps/dhcpserver/dhcpserver.c index dcc0f681..35119f9c 100644 --- a/components/lwip/apps/dhcpserver/dhcpserver.c +++ b/components/lwip/apps/dhcpserver/dhcpserver.c @@ -20,9 +20,6 @@ #include "lwip/mem.h" #include "dhcpserver/dhcpserver.h" -#ifndef LWIP_OPEN_SRC -#include "net80211/ieee80211_var.h" -#endif #ifdef MEMLEAK_DEBUG static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; @@ -354,10 +351,10 @@ static void send_offer(struct dhcps_msg* m) } #if DHCPS_DEBUG - SendOffer_err_t = udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT); + SendOffer_err_t = udp_sendto(pcb_dhcps, p, IP_ADDR_BROADCAST, DHCPS_CLIENT_PORT); os_printf("dhcps: send_offer>>udp_sendto result %x\n", SendOffer_err_t); #else - udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT); + udp_sendto(pcb_dhcps, p, IP_ADDR_BROADCAST, DHCPS_CLIENT_PORT); #endif if (p->ref != 0) { @@ -430,10 +427,10 @@ static void send_nak(struct dhcps_msg* m) } #if DHCPS_DEBUG - SendNak_err_t = udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT); + SendNak_err_t = udp_sendto(pcb_dhcps, p, IP_ADDR_BROADCAST, DHCPS_CLIENT_PORT); os_printf("dhcps: send_nak>>udp_sendto result %x\n", SendNak_err_t); #else - udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT); + udp_sendto(pcb_dhcps, p, IP_ADDR_BROADCAST, DHCPS_CLIENT_PORT); #endif if (p->ref != 0) { @@ -507,10 +504,10 @@ static void send_ack(struct dhcps_msg* m) } #if DHCPS_DEBUG - SendAck_err_t = udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT); + SendAck_err_t = udp_sendto(pcb_dhcps, p, IP_ADDR_BROADCAST, DHCPS_CLIENT_PORT); os_printf("dhcps: send_ack>>udp_sendto result %x\n", SendAck_err_t); #else - udp_sendto(pcb_dhcps, p, IP4_ADDR_BROADCAST, DHCPS_CLIENT_PORT); + udp_sendto(pcb_dhcps, p, IP_ADDR_BROADCAST, DHCPS_CLIENT_PORT); #endif if (p->ref != 0) { @@ -778,7 +775,7 @@ POOL_CHECK: memset(&client_address, 0x0, sizeof(client_address)); } - + extern bool wifi_softap_set_station_info(uint8_t*,ip4_addr_t*); if (wifi_softap_set_station_info(m->chaddr, &client_address) == false) { return 0; } diff --git a/components/lwip/apps/sntp/sntp_time.c b/components/lwip/apps/sntp/sntp_time.c index e83f7d0b..91107f4c 100644 --- a/components/lwip/apps/sntp/sntp_time.c +++ b/components/lwip/apps/sntp/sntp_time.c @@ -11,8 +11,6 @@ static s8_t sntp_time_timezone = 8; static u32_t sntp_time_realtime = 0; -static int sntp_time_month; -static int sntp_time_year; static char sntp_time_result[100]; static sntp_tm_type sntp_time_rule[2]; static sntp_tm sntp_time_result_buf; @@ -33,7 +31,6 @@ static sntp_tm *sntp_mktm_r(const sntp_time_t *tim_p, sntp_tm *res, int is_gmtim { long days, rem; sntp_time_t lcltime; - int i; int y; int yleap; const int *ip; @@ -190,61 +187,6 @@ static sntp_tm *sntp_localtime(const sntp_time_t *tim_p) return sntp_localtime_r (tim_p, &sntp_time_result_buf); } -static int sntp_limitstime(int year) -{ - int days, year_days, years; - int i, j; - - if (year < EPOCH_YEAR) - return 0; - - sntp_time_year = year; - - years = (year - EPOCH_YEAR); - - year_days = years * 365 + - (years - 1 + EPOCH_YEARS_SINCE_LEAP) / 4 - (years - 1 + EPOCH_YEARS_SINCE_CENTURY) / 100 + - (years - 1 + EPOCH_YEARS_SINCE_LEAP_CENTURY) / 400; - - for (i = 0; i < 2; ++i) - { - if (sntp_time_rule[i].ch == 'J') - days = year_days + sntp_time_rule[i].d + (isleap(year) && sntp_time_rule[i].d >= 60); - else if (sntp_time_rule[i].ch == 'D') - days = year_days + sntp_time_rule[i].d; - else - { - int yleap = isleap(year); - int m_day, m_wday, wday_diff; - const int *ip = sntp_time_mon_lengths[yleap]; - - days = year_days; - - for (j = 1; j < sntp_time_rule[i].m; ++j) - days += ip[j-1]; - - m_wday = (EPOCH_WDAY + days) % DAYSPERWEEK; - - wday_diff = sntp_time_rule[i].d - m_wday; - if (wday_diff < 0) - wday_diff += DAYSPERWEEK; - m_day = (sntp_time_rule[i].n - 1) * DAYSPERWEEK + wday_diff; - - while (m_day >= ip[j-1]) - m_day -= DAYSPERWEEK; - - days += m_day; - } - - /* store the change-over time in GMT form by adding offset */ - sntp_time_rule[i].change = days * SECSPERDAY + sntp_time_rule[i].s + sntp_time_rule[i].offset; - } - - sntp_time_month = (sntp_time_rule[0].change < sntp_time_rule[1].change); - - return 1; -} - static char *sntp_asctime_r(sntp_tm *tim_p ,char *result) { static const char day_name[7][4] = { diff --git a/components/lwip/apps/sntp/time.c b/components/lwip/apps/sntp/time.c index 878eade5..7a0d9231 100644 --- a/components/lwip/apps/sntp/time.c +++ b/components/lwip/apps/sntp/time.c @@ -20,6 +20,7 @@ */ #include "c_types.h" #include "esp_timer.h" +#include "esp_system.h" #include "lwip/apps/sntp.h" #include "lwip/apps/sntp/time.h" @@ -29,6 +30,8 @@ static os_timer_t micros_overflow_timer; static uint32 micros_at_last_overflow_tick = 0; static uint32 micros_overflow_count = 0; +extern void sntp_set_update_delay(uint32 ms); + static void micros_overflow_tick(void * arg) { uint32 m = system_get_time(); diff --git a/components/lwip/component.mk b/components/lwip/component.mk index 7c528e9d..51962617 100644 --- a/components/lwip/component.mk +++ b/components/lwip/component.mk @@ -7,4 +7,4 @@ COMPONENT_ADD_INCLUDEDIRS += lwip/src/include lwip/src/include/lwip lwip/src/inc COMPONENT_SRCDIRS += lwip/src/api lwip/src/apps/sntp lwip/src/netif lwip/src/core lwip/src/core/ipv4 lwip/src/core/ipv6 \ port/freertos port/netif apps/dhcpserver apps/sntp apps/multi-threads -CFLAGS += -D_POSIX_SOURCE -DLWIP_OPEN_SRC -DPBUF_RSV_FOR_WLAN -DEBUF_LWIP +CFLAGS += -Wno-address #lots of LWIP source files evaluate macros that check address of stack variables \ No newline at end of file diff --git a/components/lwip/include/lwip/apps/dhcpserver/dhcpserver.h b/components/lwip/include/lwip/apps/dhcpserver/dhcpserver.h index c16431ce..85cf84cf 100644 --- a/components/lwip/include/lwip/apps/dhcpserver/dhcpserver.h +++ b/components/lwip/include/lwip/apps/dhcpserver/dhcpserver.h @@ -24,20 +24,6 @@ typedef struct dhcps_msg { u8_t options[312]; } dhcps_msg; -#ifndef LWIP_OPEN_SRC -struct dhcps_lease { - bool enable; - struct ip4_addr start_ip; - struct ip4_addr end_ip; -}; - -enum dhcps_offer_option { - OFFER_START = 0x00, - OFFER_ROUTER = 0x01, - OFFER_END -}; -#endif - struct dhcps_pool { struct ip4_addr ip; u8_t mac[6]; @@ -58,7 +44,6 @@ extern u32_t dhcps_lease_time; #define DHCP_REPLY 2 #define DHCP_HTYPE_ETHERNET 1 #define DHCP_HLEN_ETHERNET 6 -#define DHCP_MSG_LEN 236 #define DHCPS_SERVER_PORT 67 #define DHCPS_CLIENT_PORT 68 diff --git a/components/lwip/include/lwip/port/lwipopts.h b/components/lwip/include/lwip/port/lwipopts.h index 7289b3e3..e149621f 100644 --- a/components/lwip/include/lwip/port/lwipopts.h +++ b/components/lwip/include/lwip/port/lwipopts.h @@ -45,6 +45,9 @@ #define __LWIP_HDR_LWIPOPTS_H__ #include "sdkconfig.h" +#include +#include "esp_libc.h" + //#define SOCKETS_MT //#define SOCKETS_TCP_TRACE @@ -190,6 +193,10 @@ /** * Use DRAM instead of IRAM */ +extern void *pvPortMalloc( size_t xWantedSize, const char * file, unsigned line, unsigned char use_iram); +extern void *pvPortZalloc( size_t xWantedSize, const char * file, unsigned line); +extern void *pvPortCalloc(size_t count, size_t size, const char * file, unsigned line); +extern void vPortFree(void *pv, const char * file, unsigned line); #define mem_clib_free os_free #define mem_clib_malloc os_malloc #define mem_clib_calloc os_calloc @@ -703,6 +710,11 @@ */ #define SNTP_SERVER_DNS 1 + +#ifndef sntp_time_t +typedef long sntp_time_t; +#endif +extern void sntp_set_system_time(sntp_time_t GMT_Time); #define SNTP_SET_SYSTEM_TIME sntp_set_system_time /* ---------------------------------- diff --git a/components/lwip/port/freertos/sys_arch.c b/components/lwip/port/freertos/sys_arch.c index efafe778..44404c5d 100644 --- a/components/lwip/port/freertos/sys_arch.c +++ b/components/lwip/port/freertos/sys_arch.c @@ -365,7 +365,7 @@ sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize xTaskHandle CreatedTask; portBASE_TYPE result; - result = xTaskCreate(thread, (signed char *)name, stacksize, arg, prio, &CreatedTask); + result = xTaskCreate(thread, (const char *)name, stacksize, arg, prio, &CreatedTask); if (result == pdPASS) { return CreatedTask;