From 40a2a8822f397a8b99790a2fd8f1b53c29b400ee Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Sat, 29 Mar 2025 18:59:01 +0000 Subject: [PATCH] Squash warning --- mongoose.c | 9 +++++---- src/net_builtin.c | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mongoose.c b/mongoose.c index c5c38179..b01b6212 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4361,11 +4361,12 @@ static const uint8_t broadcast[] = {255, 255, 255, 255, 255, 255}; // RFC-2131 #4.3.6, #4.4.1; RFC-2132 #9.8 static void tx_dhcp_request_sel(struct mg_tcpip_if *ifp, uint32_t ip_req, uint32_t ip_srv) { - uint8_t extra = (ifp->enable_req_dns ? 1 : 0) + (ifp->enable_req_sntp ? 1 : 0); + uint8_t extra = (uint8_t) ((ifp->enable_req_dns ? 1 : 0) + + (ifp->enable_req_sntp ? 1 : 0)); size_t len = strlen(ifp->dhcp_name); - size_t olen = 21 + len + extra + 2 + 1; // Total length of options + size_t olen = 21 + len + extra + 2 + 1; // Total length of options uint8_t *opts = alloca(olen), *p = opts; // Allocate options - *p++ = 53, *p++ = 1, *p++ = 3; // Type: DHCP request + *p++ = 53, *p++ = 1, *p++ = 3; // Type: DHCP request *p++ = 54, *p++ = 4, memcpy(p, &ip_srv, 4), p += 4; // DHCP server ID *p++ = 50, *p++ = 4, memcpy(p, &ip_req, 4), p += 4; // Requested IP *p++ = 12, *p++ = (uint8_t) (len & 255); // DHCP host @@ -4374,7 +4375,7 @@ static void tx_dhcp_request_sel(struct mg_tcpip_if *ifp, uint32_t ip_req, if (ifp->enable_req_dns) *p++ = 6; // DNS if (ifp->enable_req_sntp) *p++ = 42; // SNTP *p++ = 255; // End of options - assert((size_t) (p - opts) < olen); + // assert((size_t) (p - opts) < olen); tx_dhcp(ifp, (uint8_t *) broadcast, 0, 0xffffffff, opts, olen, 0); MG_DEBUG(("DHCP req sent")); } diff --git a/src/net_builtin.c b/src/net_builtin.c index 4c59437c..adfc23bd 100644 --- a/src/net_builtin.c +++ b/src/net_builtin.c @@ -280,11 +280,12 @@ static const uint8_t broadcast[] = {255, 255, 255, 255, 255, 255}; // RFC-2131 #4.3.6, #4.4.1; RFC-2132 #9.8 static void tx_dhcp_request_sel(struct mg_tcpip_if *ifp, uint32_t ip_req, uint32_t ip_srv) { - uint8_t extra = (ifp->enable_req_dns ? 1 : 0) + (ifp->enable_req_sntp ? 1 : 0); + uint8_t extra = (uint8_t) ((ifp->enable_req_dns ? 1 : 0) + + (ifp->enable_req_sntp ? 1 : 0)); size_t len = strlen(ifp->dhcp_name); - size_t olen = 21 + len + extra + 2 + 1; // Total length of options + size_t olen = 21 + len + extra + 2 + 1; // Total length of options uint8_t *opts = alloca(olen), *p = opts; // Allocate options - *p++ = 53, *p++ = 1, *p++ = 3; // Type: DHCP request + *p++ = 53, *p++ = 1, *p++ = 3; // Type: DHCP request *p++ = 54, *p++ = 4, memcpy(p, &ip_srv, 4), p += 4; // DHCP server ID *p++ = 50, *p++ = 4, memcpy(p, &ip_req, 4), p += 4; // Requested IP *p++ = 12, *p++ = (uint8_t) (len & 255); // DHCP host