Mongoose MSVC2015 warnings cleanup, part1

PUBLISHED_FROM=9e173215ed69464d1aa421d43a8fda814f36f96d
This commit is contained in:
Alexander Alashkin 2016-03-07 17:06:29 +01:00 committed by rojer
parent 796dc18cfb
commit 63be1ebd38
2 changed files with 18 additions and 11 deletions

View File

@ -564,7 +564,9 @@ double cs_time() {
* 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+ */
#endif
#include <stdio.h>
#include <stdlib.h>
@ -1454,14 +1456,15 @@ size_t mbuf_insert(struct mbuf *a, size_t off, const void *buf, size_t len) {
}
a->len += len;
} 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;
memmove(a->buf + off + len, a->buf + off, a->len - off);
if (buf != NULL) {
memcpy(a->buf + off, buf, len);
}
a->len += len;
a->size = a->len * MBUF_SIZE_MULTIPLIER;
a->size = (size_t)(a->len * MBUF_SIZE_MULTIPLIER);
} else {
len = 0;
}
@ -9089,18 +9092,18 @@ static int mg_get_ip_address_of_nameserver(char *name, size_t name_len) {
char subkey[512], value[128],
*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);
ret = -1;
} else {
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);
if (RegOpenKey(hKey, subkey, &hSub) == ERROR_SUCCESS &&
(RegQueryValueEx(hSub, "NameServer", 0, &type, (void *) value,
&len) == ERROR_SUCCESS ||
RegQueryValueEx(hSub, "DhcpNameServer", 0, &type, (void *) value,
&len) == ERROR_SUCCESS)) {
if (RegOpenKeyA(hKey, subkey, &hSub) == ERROR_SUCCESS &&
(RegQueryValueExA(hSub, "NameServer", 0, &type, (void *) value,
&len) == ERROR_SUCCESS ||
RegQueryValueExA(hSub, "DhcpNameServer", 0, &type, (void *) value,
&len) == ERROR_SUCCESS)) {
/*
* See https://github.com/cesanta/mongoose/issues/176
* The value taken from the registry can be empty, a single

View File

@ -142,6 +142,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <time.h>
#include <direct.h>
#include <io.h>
#define random() rand()
#ifdef _MSC_VER
@ -167,6 +170,7 @@
#define to64(x) _atoi64(x)
#define popen(x, y) _popen((x), (y))
#define pclose(x) _pclose(x)
#define rmdir _rmdir
#if defined(_MSC_VER) && _MSC_VER >= 1400
#define fseeko(x, y, z) _fseeki64((x), (y), (z))
#else
@ -834,8 +838,8 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#if (!(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700) && \
!(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L) && \
!(defined(__DARWIN_C_LEVEL) && __DARWIN_C_LEVEL >= 200809L) && \
!defined(RTOS_SDK)) || \
(defined(_MSC_VER) && _MSC_VER < 1600 /*Visual Studio 2010*/)
!defined(RTOS_SDK)) && \
!(defined(_MSC_VER) && _MSC_VER >= 1600 /* MSVC2013+ has strnlen */)
#define _MG_PROVIDE_STRNLEN
size_t strnlen(const char *s, size_t maxlen);
#endif