From 6c79a406cd94080b1be8cbff601f58f463be95fa Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Tue, 11 Jan 2022 19:15:38 +0000 Subject: [PATCH] Fix localtime_r and gmtmime_r signatures --- mongoose.h | 25 +++++++++++++------------ src/arch_azurertos.h | 21 +++++++++++---------- src/arch_win32.h | 4 ++-- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/mongoose.h b/mongoose.h index e43f0c7a..54898898 100644 --- a/mongoose.h +++ b/mongoose.h @@ -77,21 +77,21 @@ extern "C" { #if MG_ARCH == MG_ARCH_AZURERTOS #include -#include #include -#include +#include #include - +#include + +#include #include -#include -#include -#include #include #include +#include +#include #ifdef __REDLIB__ -#define va_copy(d,s)__builtin_va_copy(d,s) +#define va_copy(d, s) __builtin_va_copy(d, s) #endif #define PATH_MAX FX_MAXIMUM_PATH @@ -102,9 +102,10 @@ extern "C" { #define gmtime_r(a, b) gmtime(a) #define MG_INT64_FMT "%lld" -static __inline struct tm *localtime_r(time_t *t, struct tm *tm) { - (void) tm; - return localtime(t); +static __inline struct tm *localtime_r(const time_t *t, struct tm *tm) { + struct tm *x = localtime(t); + *tm = *x; + return tm; } #undef FOPEN_MAX @@ -428,13 +429,13 @@ typedef int socklen_t; #endif // https://lgtm.com/rules/2154840805/ -gmtime, localtime, ctime and asctime -static __inline struct tm *gmtime_r(time_t *t, struct tm *tm) { +static __inline struct tm *gmtime_r(const time_t *t, struct tm *tm) { struct tm *x = gmtime(t); *tm = *x; return tm; } -static __inline struct tm *localtime_r(time_t *t, struct tm *tm) { +static __inline struct tm *localtime_r(const time_t *t, struct tm *tm) { struct tm *x = localtime(t); *tm = *x; return tm; diff --git a/src/arch_azurertos.h b/src/arch_azurertos.h index 633cf33f..9f25d267 100644 --- a/src/arch_azurertos.h +++ b/src/arch_azurertos.h @@ -3,21 +3,21 @@ #if MG_ARCH == MG_ARCH_AZURERTOS #include -#include #include -#include +#include #include - +#include + +#include #include -#include -#include -#include #include #include +#include +#include #ifdef __REDLIB__ -#define va_copy(d,s)__builtin_va_copy(d,s) +#define va_copy(d, s) __builtin_va_copy(d, s) #endif #define PATH_MAX FX_MAXIMUM_PATH @@ -28,9 +28,10 @@ #define gmtime_r(a, b) gmtime(a) #define MG_INT64_FMT "%lld" -static __inline struct tm *localtime_r(time_t *t, struct tm *tm) { - (void) tm; - return localtime(t); +static __inline struct tm *localtime_r(const time_t *t, struct tm *tm) { + struct tm *x = localtime(t); + *tm = *x; + return tm; } #undef FOPEN_MAX diff --git a/src/arch_win32.h b/src/arch_win32.h index f4fdb1d6..bb1b3e21 100644 --- a/src/arch_win32.h +++ b/src/arch_win32.h @@ -90,13 +90,13 @@ typedef int socklen_t; #endif // https://lgtm.com/rules/2154840805/ -gmtime, localtime, ctime and asctime -static __inline struct tm *gmtime_r(time_t *t, struct tm *tm) { +static __inline struct tm *gmtime_r(const time_t *t, struct tm *tm) { struct tm *x = gmtime(t); *tm = *x; return tm; } -static __inline struct tm *localtime_r(time_t *t, struct tm *tm) { +static __inline struct tm *localtime_r(const time_t *t, struct tm *tm) { struct tm *x = localtime(t); *tm = *x; return tm;