diff --git a/mongoose.c b/mongoose.c index d24aaa6f..91283fe3 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4216,7 +4216,7 @@ static void mkpay(struct pkt *pkt, void *p) { static uint32_t csumup(uint32_t sum, const void *buf, size_t len) { size_t i; const uint8_t *p = (const uint8_t *) buf; - for (i = 0; i < len; i++) sum += i & 1 ? p[i] : (uint32_t) (p[i] << 8); + for (i = 0; i < len; i++) sum += i & 1 ? p[i] : ((uint32_t) p[i]) << 8; return sum; } diff --git a/src/net_builtin.c b/src/net_builtin.c index 6576bde5..e37ab9a2 100644 --- a/src/net_builtin.c +++ b/src/net_builtin.c @@ -152,7 +152,7 @@ static void mkpay(struct pkt *pkt, void *p) { static uint32_t csumup(uint32_t sum, const void *buf, size_t len) { size_t i; const uint8_t *p = (const uint8_t *) buf; - for (i = 0; i < len; i++) sum += i & 1 ? p[i] : (uint32_t) (p[i] << 8); + for (i = 0; i < len; i++) sum += i & 1 ? p[i] : ((uint32_t) p[i]) << 8; return sum; }