Squash warnings

This commit is contained in:
cpq 2022-08-09 12:39:40 +01:00
parent b7406357c5
commit 6149b619e7
3 changed files with 10 additions and 7 deletions

View File

@ -9,7 +9,8 @@ INCS ?= -Isrc -I.
SSL ?= MBEDTLS
CWD ?= $(realpath $(CURDIR))
ENV ?= -e Tmp=. -e WINEDEBUG=-all
DOCKER ?= docker run --platform linux/amd64 --rm $(ENV) -v $(CWD):$(CWD) -w $(CWD)
DOCKERCMD ?= docker
DOCKER ?= $(DOCKERCMD) run --rm $(ENV) -v $(CWD):$(CWD) -w $(CWD)
VCFLAGS = /nologo /W3 /O2 /MD /I. $(DEFS) $(TFLAGS)
IPV6 ?= 1
ASAN ?= -fsanitize=address,undefined -fno-sanitize-recover=all

View File

@ -3912,8 +3912,8 @@ void mg_sha1_final(unsigned char digest[20], mg_sha1_ctx *context) {
#define SNTP_TIME_OFFSET 2208988800UL // (1970 - 1900) in seconds
#define SNTP_MAX_FRAC 4294967295.0 // 2 ** 32 - 1
#define SNTP_TIME_OFFSET 2208988800U // (1970 - 1900) in seconds
#define SNTP_MAX_FRAC 4294967295.0 // 2 ** 32 - 1
static int64_t gettimestamp(const uint32_t *data) {
uint32_t sec = mg_ntohl(data[0]), frac = mg_ntohl(data[1]);
@ -3970,9 +3970,10 @@ void mg_sntp_request(struct mg_connection *c) {
uint64_t now = mg_millis();
uint8_t buf[48] = {0};
uint32_t *t = (uint32_t *) &buf[40];
double frac = ((double) (now % 1000)) / 1000.0;
buf[0] = (0 << 6) | (4 << 3) | 3;
t[0] = mg_htonl((uint32_t) (now / 1000) + SNTP_TIME_OFFSET);
t[1] = mg_htonl((uint32_t) ((now % 1000) / 1000.0 * SNTP_MAX_FRAC));
t[1] = mg_htonl((uint32_t) ((uint32_t) (frac * SNTP_MAX_FRAC)));
mg_send(c, buf, sizeof(buf));
}
}

View File

@ -4,8 +4,8 @@
#include "log.h"
#include "util.h"
#define SNTP_TIME_OFFSET 2208988800UL // (1970 - 1900) in seconds
#define SNTP_MAX_FRAC 4294967295.0 // 2 ** 32 - 1
#define SNTP_TIME_OFFSET 2208988800U // (1970 - 1900) in seconds
#define SNTP_MAX_FRAC 4294967295.0 // 2 ** 32 - 1
static int64_t gettimestamp(const uint32_t *data) {
uint32_t sec = mg_ntohl(data[0]), frac = mg_ntohl(data[1]);
@ -62,9 +62,10 @@ void mg_sntp_request(struct mg_connection *c) {
uint64_t now = mg_millis();
uint8_t buf[48] = {0};
uint32_t *t = (uint32_t *) &buf[40];
double frac = ((double) (now % 1000)) / 1000.0;
buf[0] = (0 << 6) | (4 << 3) | 3;
t[0] = mg_htonl((uint32_t) (now / 1000) + SNTP_TIME_OFFSET);
t[1] = mg_htonl((uint32_t) ((now % 1000) / 1000.0 * SNTP_MAX_FRAC));
t[1] = mg_htonl((uint32_t) ((uint32_t) (frac * SNTP_MAX_FRAC)));
mg_send(c, buf, sizeof(buf));
}
}