diff --git a/src/shrpx_client_handler.cc b/src/shrpx_client_handler.cc index 1e05e350..2c9b2a10 100644 --- a/src/shrpx_client_handler.cc +++ b/src/shrpx_client_handler.cc @@ -687,7 +687,9 @@ uint32_t compute_affinity_from_ip(const StringRef &ip) { return util::hash32(ip); } - return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; + return (static_cast(buf[0]) << 24) | + (static_cast(buf[1]) << 16) | + (static_cast(buf[2]) << 8) | static_cast(buf[3]); } } // namespace diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index 3d27e6f2..f356a3fb 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -2854,8 +2854,10 @@ int compute_affinity_hash(std::vector &res, size_t idx, } for (int i = 0; i < 8; ++i) { - auto h = (buf[4 * i] << 24) | (buf[4 * i + 1] << 16) | - (buf[4 * i + 2] << 8) | buf[4 * i + 3]; + auto h = (static_cast(buf[4 * i]) << 24) | + (static_cast(buf[4 * i + 1]) << 16) | + (static_cast(buf[4 * i + 2]) << 8) | + static_cast(buf[4 * i + 3]); res.emplace_back(idx, h); }