Skip to content

Commit

Permalink
🚨 fix compiler warnings #2049
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Apr 19, 2020
1 parent be13760 commit 4fb0795
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/nlohmann/detail/conversions/to_chars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,

std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(k) - static_cast<size_t>(n));
buf[n] = '.';
return buf + (static_cast<size_t>(k) + 1);
return buf + (static_cast<size_t>(k) + 1U);
}

if (min_exp < n and n <= 0)
Expand All @@ -1018,7 +1018,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
buf[0] = '0';
buf[1] = '.';
std::memset(buf + 2, '0', static_cast<size_t>(-n));
return buf + (2 + static_cast<size_t>(-n) + k);
return buf + (2U + static_cast<size_t>(-n) + static_cast<size_t>(k));
}

if (k == 1)
Expand Down
3 changes: 1 addition & 2 deletions include/nlohmann/detail/output/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ class serializer
{
dump_integer(*i);
o->write_character(',');
int index = i - val.m_value.binary->cbegin();
if (index % 16 == 0)
if (std::distance(val.m_value.binary->cbegin(), i) % 16 == 0)
{
o->write_character('\n');
}
Expand Down
7 changes: 3 additions & 4 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14543,7 +14543,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,

std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(k) - static_cast<size_t>(n));
buf[n] = '.';
return buf + (static_cast<size_t>(k) + 1);
return buf + (static_cast<size_t>(k) + 1U);
}

if (min_exp < n and n <= 0)
Expand All @@ -14555,7 +14555,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
buf[0] = '0';
buf[1] = '.';
std::memset(buf + 2, '0', static_cast<size_t>(-n));
return buf + (2 + static_cast<size_t>(-n) + k);
return buf + (2U + static_cast<size_t>(-n) + static_cast<size_t>(k));
}

if (k == 1)
Expand Down Expand Up @@ -14892,8 +14892,7 @@ class serializer
{
dump_integer(*i);
o->write_character(',');
int index = i - val.m_value.binary->cbegin();
if (index % 16 == 0)
if (std::distance(val.m_value.binary->cbegin(), i) % 16 == 0)
{
o->write_character('\n');
}
Expand Down
2 changes: 1 addition & 1 deletion test/src/unit-deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct SaxEventLogger : public nlohmann::json_sax<json>
return true;
}

bool binary(std::vector<std::uint8_t>& val)
bool binary(std::vector<std::uint8_t>& val) override
{
std::string binary_contents = "binary(";
std::string comma_space = "";
Expand Down

0 comments on commit 4fb0795

Please sign in to comment.