Skip to content

Commit

Permalink
Merge pull request zeromq#578 from Teebonne/patch-1
Browse files Browse the repository at this point in the history
 Disambiguation from other max functions
  • Loading branch information
gummif authored Oct 10, 2022
2 parents d67b635 + dc151e2 commit 2aee6cd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions zmq_addon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ inline bool is_little_endian()
inline void write_network_order(unsigned char *buf, const uint32_t value)
{
if (is_little_endian()) {
ZMQ_CONSTEXPR_VAR uint32_t mask = std::numeric_limits<std::uint8_t>::max();
ZMQ_CONSTEXPR_VAR uint32_t mask = (std::numeric_limits<std::uint8_t>::max)();
*buf++ = static_cast<unsigned char>((value >> 24) & mask);
*buf++ = static_cast<unsigned char>((value >> 16) & mask);
*buf++ = static_cast<unsigned char>((value >> 8) & mask);
Expand Down Expand Up @@ -224,12 +224,12 @@ message_t encode(const Range &parts)
// First pass check sizes
for (const auto &part : parts) {
const size_t part_size = part.size();
if (part_size > std::numeric_limits<std::uint32_t>::max()) {
if (part_size > (std::numeric_limits<std::uint32_t>::max)()) {
// Size value must fit into uint32_t.
throw std::range_error("Invalid size, message part too large");
}
const size_t count_size =
part_size < std::numeric_limits<std::uint8_t>::max() ? 1 : 5;
part_size < (std::numeric_limits<std::uint8_t>::max)() ? 1 : 5;
mmsg_size += part_size + count_size;
}

Expand All @@ -240,12 +240,12 @@ message_t encode(const Range &parts)
const unsigned char *part_data =
static_cast<const unsigned char *>(part.data());

if (part_size < std::numeric_limits<std::uint8_t>::max()) {
if (part_size < (std::numeric_limits<std::uint8_t>::max)()) {
// small part
*buf++ = (unsigned char) part_size;
} else {
// big part
*buf++ = std::numeric_limits<uint8_t>::max();
*buf++ = (std::numeric_limits<uint8_t>::max)();
detail::write_network_order(buf, part_size);
buf += sizeof(part_size);
}
Expand Down Expand Up @@ -279,7 +279,7 @@ template<class OutputIt> OutputIt decode(const message_t &encoded, OutputIt out)

while (source < limit) {
size_t part_size = *source++;
if (part_size == std::numeric_limits<std::uint8_t>::max()) {
if (part_size == (std::numeric_limits<std::uint8_t>::max)()) {
if (static_cast<size_t>(limit - source) < sizeof(uint32_t)) {
throw std::out_of_range(
"Malformed encoding, overflow in reading size");
Expand Down

0 comments on commit 2aee6cd

Please sign in to comment.