From e5585cb0e7e935845533ee53dde5609238c27920 Mon Sep 17 00:00:00 2001 From: cpq Date: Tue, 9 Aug 2022 18:58:58 +0100 Subject: [PATCH] Squash vc98 warn 2 --- mongoose.c | 4 ++-- src/sntp.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mongoose.c b/mongoose.c index 206b5b31..10beca39 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3970,10 +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; + double frac = ((double) (now % 1000)) / 1000.0 * SNTP_MAX_FRAC; buf[0] = (0 << 6) | (4 << 3) | 3; t[0] = mg_htonl((uint32_t) (now / 1000) + SNTP_TIME_OFFSET); - t[1] = mg_htonl((uint32_t) ((int32_t) (frac * SNTP_MAX_FRAC))); + t[1] = mg_htonl((uint32_t) frac); mg_send(c, buf, sizeof(buf)); } } diff --git a/src/sntp.c b/src/sntp.c index 4f4dff1b..a352622c 100644 --- a/src/sntp.c +++ b/src/sntp.c @@ -62,10 +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; + double frac = ((double) (now % 1000)) / 1000.0 * SNTP_MAX_FRAC; buf[0] = (0 << 6) | (4 << 3) | 3; t[0] = mg_htonl((uint32_t) (now / 1000) + SNTP_TIME_OFFSET); - t[1] = mg_htonl((uint32_t) ((int32_t) (frac * SNTP_MAX_FRAC))); + t[1] = mg_htonl((uint32_t) frac); mg_send(c, buf, sizeof(buf)); } }