Commit 63be1ebd authored by Alexander Alashkin's avatar Alexander Alashkin Committed by rojer

Mongoose MSVC2015 warnings cleanup, part1

    PUBLISHED_FROM=9e173215ed69464d1aa421d43a8fda814f36f96d
parent 796dc18c
...@@ -564,7 +564,9 @@ double cs_time() { ...@@ -564,7 +564,9 @@ double cs_time() {
* license, as set out in <http://cesanta.com/products.html>. * license, as set out in <http://cesanta.com/products.html>.
*/ */
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in VS2005+ */ #define _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in VS2005+ */
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -1454,14 +1456,15 @@ size_t mbuf_insert(struct mbuf *a, size_t off, const void *buf, size_t len) { ...@@ -1454,14 +1456,15 @@ size_t mbuf_insert(struct mbuf *a, size_t off, const void *buf, size_t len) {
} }
a->len += len; a->len += len;
} else if ((p = (char *) MBUF_REALLOC( } else if ((p = (char *) MBUF_REALLOC(
a->buf, (a->len + len) * MBUF_SIZE_MULTIPLIER)) != NULL) { a->buf, (size_t)((a->len + len) * MBUF_SIZE_MULTIPLIER))) !=
NULL) {
a->buf = p; a->buf = p;
memmove(a->buf + off + len, a->buf + off, a->len - off); memmove(a->buf + off + len, a->buf + off, a->len - off);
if (buf != NULL) { if (buf != NULL) {
memcpy(a->buf + off, buf, len); memcpy(a->buf + off, buf, len);
} }
a->len += len; a->len += len;
a->size = a->len * MBUF_SIZE_MULTIPLIER; a->size = (size_t)(a->len * MBUF_SIZE_MULTIPLIER);
} else { } else {
len = 0; len = 0;
} }
...@@ -9089,18 +9092,18 @@ static int mg_get_ip_address_of_nameserver(char *name, size_t name_len) { ...@@ -9089,18 +9092,18 @@ static int mg_get_ip_address_of_nameserver(char *name, size_t name_len) {
char subkey[512], value[128], char subkey[512], value[128],
*key = "SYSTEM\\ControlSet001\\Services\\Tcpip\\Parameters\\Interfaces"; *key = "SYSTEM\\ControlSet001\\Services\\Tcpip\\Parameters\\Interfaces";
if ((err = RegOpenKey(HKEY_LOCAL_MACHINE, key, &hKey)) != ERROR_SUCCESS) { if ((err = RegOpenKeyA(HKEY_LOCAL_MACHINE, key, &hKey)) != ERROR_SUCCESS) {
fprintf(stderr, "cannot open reg key %s: %d\n", key, err); fprintf(stderr, "cannot open reg key %s: %d\n", key, err);
ret = -1; ret = -1;
} else { } else {
for (ret = -1, i = 0; for (ret = -1, i = 0;
RegEnumKey(hKey, i, subkey, sizeof(subkey)) == ERROR_SUCCESS; i++) { RegEnumKeyA(hKey, i, subkey, sizeof(subkey)) == ERROR_SUCCESS; i++) {
DWORD type, len = sizeof(value); DWORD type, len = sizeof(value);
if (RegOpenKey(hKey, subkey, &hSub) == ERROR_SUCCESS && if (RegOpenKeyA(hKey, subkey, &hSub) == ERROR_SUCCESS &&
(RegQueryValueEx(hSub, "NameServer", 0, &type, (void *) value, (RegQueryValueExA(hSub, "NameServer", 0, &type, (void *) value,
&len) == ERROR_SUCCESS || &len) == ERROR_SUCCESS ||
RegQueryValueEx(hSub, "DhcpNameServer", 0, &type, (void *) value, RegQueryValueExA(hSub, "DhcpNameServer", 0, &type, (void *) value,
&len) == ERROR_SUCCESS)) { &len) == ERROR_SUCCESS)) {
/* /*
* See https://github.com/cesanta/mongoose/issues/176 * See https://github.com/cesanta/mongoose/issues/176
* The value taken from the registry can be empty, a single * The value taken from the registry can be empty, a single
......
...@@ -142,6 +142,9 @@ ...@@ -142,6 +142,9 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <time.h>
#include <direct.h>
#include <io.h>
#define random() rand() #define random() rand()
#ifdef _MSC_VER #ifdef _MSC_VER
...@@ -167,6 +170,7 @@ ...@@ -167,6 +170,7 @@
#define to64(x) _atoi64(x) #define to64(x) _atoi64(x)
#define popen(x, y) _popen((x), (y)) #define popen(x, y) _popen((x), (y))
#define pclose(x) _pclose(x) #define pclose(x) _pclose(x)
#define rmdir _rmdir
#if defined(_MSC_VER) && _MSC_VER >= 1400 #if defined(_MSC_VER) && _MSC_VER >= 1400
#define fseeko(x, y, z) _fseeki64((x), (y), (z)) #define fseeko(x, y, z) _fseeki64((x), (y), (z))
#else #else
...@@ -834,8 +838,8 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -834,8 +838,8 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#if (!(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700) && \ #if (!(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700) && \
!(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L) && \ !(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L) && \
!(defined(__DARWIN_C_LEVEL) && __DARWIN_C_LEVEL >= 200809L) && \ !(defined(__DARWIN_C_LEVEL) && __DARWIN_C_LEVEL >= 200809L) && \
!defined(RTOS_SDK)) || \ !defined(RTOS_SDK)) && \
(defined(_MSC_VER) && _MSC_VER < 1600 /*Visual Studio 2010*/) !(defined(_MSC_VER) && _MSC_VER >= 1600 /* MSVC2013+ has strnlen */)
#define _MG_PROVIDE_STRNLEN #define _MG_PROVIDE_STRNLEN
size_t strnlen(const char *s, size_t maxlen); size_t strnlen(const char *s, size_t maxlen);
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment