From 838b0bcd2740473612010f966637fe433eb2ebac Mon Sep 17 00:00:00 2001 From: cpq Date: Fri, 28 May 2021 18:45:35 +0100 Subject: [PATCH] Squash more warnings --- Makefile | 3 ++- mongoose.c | 8 ++++---- src/base64.c | 2 +- src/dns.c | 4 ++-- src/mqtt.c | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index fb13e503..1512fe5d 100644 --- a/Makefile +++ b/Makefile @@ -96,7 +96,8 @@ linux: Makefile mongoose.c mongoose.h test/unit_test.c $(GCC) $(CC) mongoose.c test/unit_test.c $(CFLAGS) $(LDFLAGS) -o unit_test_gcc $(GCC) ./unit_test_gcc -linux++: CC = g++ -Wno-missing-field-initializers +linux++: CC = g++ +linux++: WARN += -Wno-shadow # Ignore "hides constructor for 'struct mg_str'" linux++: linux arm: Makefile mongoose.c mongoose.h test/unit_test.c diff --git a/mongoose.c b/mongoose.c index e6394504..89f47a64 100644 --- a/mongoose.c +++ b/mongoose.c @@ -58,7 +58,7 @@ static int mg_b64rev(int c) { } int mg_base64_update(unsigned char ch, char *to, int n) { - unsigned char rem = (n & 3) % 3; + int rem = (n & 3) % 3; if (rem == 0) { to[n] = (char) mg_b64idx(ch >> 2); to[++n] = (char) ((ch & 3) << 4); @@ -197,7 +197,7 @@ size_t mg_dns_parse_rr(const uint8_t *buf, size_t len, size_t ofs, if (s > e) return 0; rr->atype = (uint16_t)(((uint16_t) s[-4] << 8) | s[-3]); rr->aclass = (uint16_t)(((uint16_t) s[-2] << 8) | s[-1]); - if (is_question) return rr->nlen + 4; + if (is_question) return (size_t)(rr->nlen + 4); s += 6; if (s > e) return 0; @@ -358,7 +358,7 @@ static void mg_sendnsreq(struct mg_connection *c, struct mg_str *name, int ms, #if MG_ENABLE_LOG char buf[100]; #endif - d->txnid = s_reqs ? s_reqs->txnid + 1 : 1; + d->txnid = s_reqs ? (uint16_t)(s_reqs->txnid + 1) : 1; d->next = s_reqs; s_reqs = d; d->expire = mg_millis() + (unsigned long) ms; @@ -1956,7 +1956,7 @@ int mg_mqtt_parse(const uint8_t *buf, size_t len, struct mg_mqtt_message *m) { memset(m, 0, sizeof(*m)); m->dgram.ptr = (char *) buf; if (len < 2) return MQTT_INCOMPLETE; - m->cmd = buf[0] >> 4; + m->cmd = (uint8_t)(buf[0] >> 4); m->qos = (buf[0] >> 1) & 3; n = len_len = 0; diff --git a/src/base64.c b/src/base64.c index f6ea7400..5989f67b 100644 --- a/src/base64.c +++ b/src/base64.c @@ -31,7 +31,7 @@ static int mg_b64rev(int c) { } int mg_base64_update(unsigned char ch, char *to, int n) { - unsigned char rem = (n & 3) % 3; + int rem = (n & 3) % 3; if (rem == 0) { to[n] = (char) mg_b64idx(ch >> 2); to[++n] = (char) ((ch & 3) << 4); diff --git a/src/dns.c b/src/dns.c index 1a54b0af..6318c537 100644 --- a/src/dns.c +++ b/src/dns.c @@ -83,7 +83,7 @@ size_t mg_dns_parse_rr(const uint8_t *buf, size_t len, size_t ofs, if (s > e) return 0; rr->atype = (uint16_t)(((uint16_t) s[-4] << 8) | s[-3]); rr->aclass = (uint16_t)(((uint16_t) s[-2] << 8) | s[-1]); - if (is_question) return rr->nlen + 4; + if (is_question) return (size_t)(rr->nlen + 4); s += 6; if (s > e) return 0; @@ -244,7 +244,7 @@ static void mg_sendnsreq(struct mg_connection *c, struct mg_str *name, int ms, #if MG_ENABLE_LOG char buf[100]; #endif - d->txnid = s_reqs ? s_reqs->txnid + 1 : 1; + d->txnid = s_reqs ? (uint16_t)(s_reqs->txnid + 1) : 1; d->next = s_reqs; s_reqs = d; d->expire = mg_millis() + (unsigned long) ms; diff --git a/src/mqtt.c b/src/mqtt.c index 88276388..3a198987 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -119,7 +119,7 @@ int mg_mqtt_parse(const uint8_t *buf, size_t len, struct mg_mqtt_message *m) { memset(m, 0, sizeof(*m)); m->dgram.ptr = (char *) buf; if (len < 2) return MQTT_INCOMPLETE; - m->cmd = buf[0] >> 4; + m->cmd = (uint8_t)(buf[0] >> 4); m->qos = (buf[0] >> 1) & 3; n = len_len = 0;