From 25bc13ef1e486409e80295c4923d6b93627155e1 Mon Sep 17 00:00:00 2001 From: cpq Date: Thu, 24 Dec 2020 07:26:50 +0000 Subject: [PATCH] Squash some warnings under mingw crosscompiler --- mongoose.c | 3 ++- mongoose.h | 5 +++-- src/arch_win32.h | 5 +++-- src/net.c | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mongoose.c b/mongoose.c index 6561729a..ec9ab0d8 100644 --- a/mongoose.c +++ b/mongoose.c @@ -1968,7 +1968,8 @@ char *mg_straddr(struct mg_connection *c, char *buf, size_t len) { char *mg_ntoa(const struct mg_addr *addr, char *buf, size_t len) { uint8_t p[4]; memcpy(p, &addr->ip, sizeof(p)); - snprintf(buf, len, "%hhu.%hhu.%hhu.%hhu", p[0], p[1], p[2], p[3]); + snprintf(buf, len, "%d.%d.%d.%d", (int) p[0], (int) p[1], (int) p[2], + (int) p[3]); return buf; } diff --git a/mongoose.h b/mongoose.h index 75a9a5cf..158222e0 100644 --- a/mongoose.h +++ b/mongoose.h @@ -264,8 +264,10 @@ enum { false = 0, true = 1 }; #endif typedef int socklen_t; -#define PATH_MAX MAX_PATH #define MG_DIRSEP '\\' +#ifndef PATH_MAX +#define PATH_MAX MAX_PATH +#endif #ifndef EINPROGRESS #define EINPROGRESS WSAEINPROGRESS #endif @@ -280,7 +282,6 @@ typedef int socklen_t; #define va_copy(x, y) (x) = (y) #endif #endif - #ifndef S_ISDIR #define S_ISDIR(x) (((x) &_S_IFMT) == _S_IFDIR) #endif diff --git a/src/arch_win32.h b/src/arch_win32.h index f12aafa8..8351c157 100644 --- a/src/arch_win32.h +++ b/src/arch_win32.h @@ -28,8 +28,10 @@ enum { false = 0, true = 1 }; #endif typedef int socklen_t; -#define PATH_MAX MAX_PATH #define MG_DIRSEP '\\' +#ifndef PATH_MAX +#define PATH_MAX MAX_PATH +#endif #ifndef EINPROGRESS #define EINPROGRESS WSAEINPROGRESS #endif @@ -44,7 +46,6 @@ typedef int socklen_t; #define va_copy(x, y) (x) = (y) #endif #endif - #ifndef S_ISDIR #define S_ISDIR(x) (((x) &_S_IFMT) == _S_IFDIR) #endif diff --git a/src/net.c b/src/net.c index a2b40cfc..aeb3b15f 100644 --- a/src/net.c +++ b/src/net.c @@ -38,7 +38,8 @@ char *mg_straddr(struct mg_connection *c, char *buf, size_t len) { char *mg_ntoa(const struct mg_addr *addr, char *buf, size_t len) { uint8_t p[4]; memcpy(p, &addr->ip, sizeof(p)); - snprintf(buf, len, "%hhu.%hhu.%hhu.%hhu", p[0], p[1], p[2], p[3]); + snprintf(buf, len, "%d.%d.%d.%d", (int) p[0], (int) p[1], (int) p[2], + (int) p[3]); return buf; }