From 2ea5e8afa318d38402dbebe360c37e51a2aaa0c5 Mon Sep 17 00:00:00 2001 From: "tarun.kumar" Date: Wed, 22 Jan 2025 10:57:36 +0530 Subject: [PATCH] fix(esp_wifi): Modifying os_time_t datatype for platform and compiler independence --- components/esp_wifi/lib | 2 +- components/wpa_supplicant/port/include/os.h | 60 ++++++++++--------- .../wpa_supplicant/src/wps/wps_registrar.c | 4 +- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index b328e5edbe..b3fbda3436 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit b328e5edbe8c91ee751945953407d183ef119001 +Subproject commit b3fbda3436293689ed80dd3dfbe4106dd3b697bc diff --git a/components/wpa_supplicant/port/include/os.h b/components/wpa_supplicant/port/include/os.h index 5e95c17fec..679507436b 100644 --- a/components/wpa_supplicant/port/include/os.h +++ b/components/wpa_supplicant/port/include/os.h @@ -24,7 +24,9 @@ #include "esp_private/esp_wifi_private.h" #include "esp_wifi.h" -typedef time_t os_time_t; +/* Modifying datatype for platform and compiler independence */ + +typedef uint64_t os_time_t; /** * os_sleep - Sleep (sec, usec) @@ -34,8 +36,8 @@ typedef time_t os_time_t; void os_sleep(os_time_t sec, os_time_t usec); struct os_time { - os_time_t sec; - suseconds_t usec; + os_time_t sec; + suseconds_t usec; }; #define os_reltime os_time @@ -60,17 +62,17 @@ int os_get_time(struct os_time *t); /* Helper macros for handling struct os_time */ #define os_time_before(a, b) \ - ((a)->sec < (b)->sec || \ - ((a)->sec == (b)->sec && (a)->usec < (b)->usec)) + ((a)->sec < (b)->sec || \ + ((a)->sec == (b)->sec && (a)->usec < (b)->usec)) #define os_reltime_before os_time_before #define os_time_sub(a, b, res) do { \ - (res)->sec = (a)->sec - (b)->sec; \ - (res)->usec = (a)->usec - (b)->usec; \ - if ((res)->usec < 0) { \ - (res)->sec--; \ - (res)->usec += 1000000; \ - } \ + (res)->sec = (a)->sec - (b)->sec; \ + (res)->usec = (a)->usec - (b)->usec; \ + if ((res)->usec < 0) { \ + (res)->sec--; \ + (res)->usec += 1000000; \ + } \ } while (0) #define os_reltime_sub os_time_sub @@ -90,7 +92,7 @@ int os_get_time(struct os_time *t); * which is used by POSIX mktime(). */ int os_mktime(int year, int month, int day, int hour, int min, int sec, - os_time_t *t); + os_time_t *t); int os_gmtime(os_time_t t, struct os_tm *tm); @@ -191,7 +193,7 @@ int os_unsetenv(const char *name); /* We don't support file reading support */ static inline char *os_readfile(const char *name, size_t *len) { - return NULL; + return NULL; } /* @@ -231,7 +233,6 @@ static inline char *os_readfile(const char *name, size_t *len) #define os_bzero(s, n) bzero(s, n) #endif - #ifndef os_strdup #ifdef _MSC_VER #define os_strdup(s) _strdup(s) @@ -309,14 +310,15 @@ char * ets_strdup(const char *s); static inline int os_snprintf_error(size_t size, int res) { - return res < 0 || (unsigned int) res >= size; + return res < 0 || (unsigned int) res >= size; } static inline void * os_realloc_array(void *ptr, size_t nmemb, size_t size) { - if (size && nmemb > (~(size_t) 0) / size) - return NULL; - return os_realloc(ptr, nmemb * size); + if (size && nmemb > (~(size_t) 0) / size) { + return NULL; + } + return os_realloc(ptr, nmemb * size); } #ifdef CONFIG_CRYPTO_MBEDTLS @@ -335,10 +337,10 @@ static uint8_t forced_memzero_val; static inline void forced_memzero(void *ptr, size_t len) { - memset_func(ptr, 0, len); - if (len) { - forced_memzero_val = ((uint8_t *) ptr)[0]; - } + memset_func(ptr, 0, len); + if (len) { + forced_memzero_val = ((uint8_t *) ptr)[0]; + } } #endif @@ -378,23 +380,23 @@ extern const wifi_osi_funcs_t *wifi_funcs; static inline void os_timer_setfn(void *ptimer, void *pfunction, void *parg) { - return wifi_funcs->_timer_setfn(ptimer, pfunction, parg); + return wifi_funcs->_timer_setfn(ptimer, pfunction, parg); } static inline void os_timer_disarm(void *ptimer) { - return wifi_funcs->_timer_disarm(ptimer); + return wifi_funcs->_timer_disarm(ptimer); } -static inline void os_timer_arm_us(void *ptimer,uint32_t u_seconds,bool repeat_flag) +static inline void os_timer_arm_us(void *ptimer, uint32_t u_seconds, bool repeat_flag) { - return wifi_funcs->_timer_arm_us(ptimer, u_seconds, repeat_flag); + return wifi_funcs->_timer_arm_us(ptimer, u_seconds, repeat_flag); } -static inline void os_timer_arm(void *ptimer,uint32_t milliseconds,bool repeat_flag) +static inline void os_timer_arm(void *ptimer, uint32_t milliseconds, bool repeat_flag) { - return wifi_funcs->_timer_arm(ptimer, milliseconds, repeat_flag); + return wifi_funcs->_timer_arm(ptimer, milliseconds, repeat_flag); } static inline void os_timer_done(void *ptimer) { - return wifi_funcs->_timer_done(ptimer); + return wifi_funcs->_timer_done(ptimer); } #endif /* OS_H */ diff --git a/components/wpa_supplicant/src/wps/wps_registrar.c b/components/wpa_supplicant/src/wps/wps_registrar.c index a7edf79ff6..462e16c5df 100644 --- a/components/wpa_supplicant/src/wps/wps_registrar.c +++ b/components/wpa_supplicant/src/wps/wps_registrar.c @@ -1209,7 +1209,9 @@ void wps_registrar_probe_req_rx(struct wps_registrar *reg, const u8 *addr, struct os_reltime now, dur; os_get_reltime(&now); os_reltime_sub(&now, ®->pbc_ignore_start, &dur); - if (dur.sec >= 0 && dur.sec < 5) { +#ifdef ESP_SUPPLICANT + if (dur.sec < 5) { +#endif /* ESP_SUPPLICANT */ wpa_printf(MSG_DEBUG, "WPS: Ignore PBC activation " "based on Probe Request from the Enrollee " "that just completed PBC provisioning");