From fd839f18275e5fde419497a254c129c6ad764b42 Mon Sep 17 00:00:00 2001 From: Artem Bulavin <hdr.dmc@gmail.com> Date: Fri, 19 Aug 2016 10:52:40 +0200 Subject: [PATCH] Pointer to int casting warning PUBLISHED_FROM=6bf2a710edaae6133d68eaf900ede14bba75ad5a --- mongoose.c | 4 ++-- mongoose.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index 29bd8c86e..ae41af207 100644 --- a/mongoose.c +++ b/mongoose.c @@ -1509,7 +1509,7 @@ int c_vsnprintf(char *buf, size_t buf_size, const char *fmt, va_list ap) { i += c_itoa(buf + i, buf_size - i, va_arg(ap, size_t), ch == 'x' ? 16 : 10, flags, field_width); } else if (ch == 'p') { - unsigned long num = (unsigned long) va_arg(ap, void *); + unsigned long num = (unsigned long) (uintptr_t) va_arg(ap, void *); C_SNPRINTF_APPEND_CHAR('0'); C_SNPRINTF_APPEND_CHAR('x'); i += c_itoa(buf + i, buf_size - i, num, 16, flags, 0); @@ -5151,7 +5151,7 @@ void mg_send_websocket_handshake2(struct mg_connection *nc, const char *path, const char *host, const char *protocol, const char *extra_headers) { /* pretty poor source of randomness, TODO fix */ - unsigned long random = (unsigned long) path; + unsigned long random = (unsigned long) (uintptr_t) path; char key[sizeof(random) * 3]; mg_base64_encode((unsigned char *) &random, sizeof(random), key); diff --git a/mongoose.h b/mongoose.h index 27ef6fe6e..3a7a0935e 100644 --- a/mongoose.h +++ b/mongoose.h @@ -186,6 +186,9 @@ #else #define fseeko(x, y, z) fseek((x), (y), (z)) #endif +#if defined(_MSC_VER) && _MSC_VER <= 1200 +typedef unsigned long uintptr_t; +#endif typedef int socklen_t; #if _MSC_VER >= 1700 #include <stdint.h> -- GitLab