Windows C4267 errors: Fix size_t conversion warnings in windows builds

examples/client.c:
examples/coap-rd.c:
examples/coap-server.c:
include/coap2/block.h:
include/coap2/coap_hashkey.h:
src/block.c:
src/coap_debug.c:
src/coap_hashkey.c:
src/coap_io.c:
src/coap_openssl.c:
src/net.c:

Fix C4267 windows compilation warnings when using Visual Studio where
size_t variable parameters are being converted  in both size and sign.

There still are some C4116 warnings to fix.
This commit is contained in:
Jon Shallow committed 2020-02-21 17:28:11 +00:00
1 parent 636a4df2b5
commit bb38e995bc
11 files changed
+34 -32

No files matched your search

+5 -3
View File
@@ -35,6 +35,8 @@ static char* strndup(const char* s1, size_t n)
}
return copy;
};
#include <io.h>
#define access _access
#else
#include <unistd.h>
#include <sys/select.h>
@@ -320,10 +322,11 @@ check_async(coap_context_t *ctx,
coap_tick_t now) {
coap_pdu_t *response;
coap_async_state_t *tmp;
async_data_t data = { .ptr = async ? async->appdata : NULL };
size_t size = 13;
if (!async || now < async->created + (unsigned long)async->appdata)
if (!async || now < async->created + data.val)
return;
response = coap_pdu_init(async->flags & COAP_ASYNC_CONFIRM
@@ -332,7 +335,6 @@ check_async(coap_context_t *ctx,
COAP_RESPONSE_CODE(205), 0, size);
if (!response) {
coap_log(LOG_DEBUG, "check_async: insufficient memory, we'll try later\n");
async_data_t data = { .ptr = async->appdata };
data.val = data.val + 15 * COAP_TICKS_PER_SECOND;
async->appdata = data.ptr;
return;
@@ -1075,7 +1077,7 @@ get_context(const char *node, const char *port) {
if (rp->ai_addrlen <= sizeof(addr.addr)) {
coap_address_init(&addr);
addr.size = rp->ai_addrlen;
addr.size = (socklen_t)rp->ai_addrlen;
memcpy(&addr.addr, rp->ai_addr, rp->ai_addrlen);
addrs = addr;
if (addr.addr.sa.sa_family == AF_INET) {