Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disambiguation from other max functions #578

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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