🏁 adding parentheses around std::snprintf calls #1337
This commit is contained in:
parent
f80efd3954
commit
da81e7be22
4 changed files with 22 additions and 22 deletions
|
@ -264,7 +264,7 @@ class binary_reader
|
||||||
default: // anything else not supported (yet)
|
default: // anything else not supported (yet)
|
||||||
{
|
{
|
||||||
char cr[3];
|
char cr[3];
|
||||||
snprintf(cr, sizeof(cr), "%.2hhX", static_cast<unsigned char>(element_type));
|
(std::snprintf)(cr, sizeof(cr), "%.2hhX", static_cast<unsigned char>(element_type));
|
||||||
return sax->parse_error(element_type_parse_position, std::string(cr), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr)));
|
return sax->parse_error(element_type_parse_position, std::string(cr), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1921,7 +1921,7 @@ class binary_reader
|
||||||
std::string get_token_string() const
|
std::string get_token_string() const
|
||||||
{
|
{
|
||||||
char cr[3];
|
char cr[3];
|
||||||
snprintf(cr, 3, "%.2hhX", static_cast<unsigned char>(current));
|
(std::snprintf)(cr, 3, "%.2hhX", static_cast<unsigned char>(current));
|
||||||
return std::string{cr};
|
return std::string{cr};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1360,7 +1360,7 @@ scan_number_done:
|
||||||
{
|
{
|
||||||
// escape control characters
|
// escape control characters
|
||||||
char cs[9];
|
char cs[9];
|
||||||
snprintf(cs, 9, "<U+%.4X>", static_cast<unsigned char>(c));
|
(std::snprintf)(cs, 9, "<U+%.4X>", static_cast<unsigned char>(c));
|
||||||
result += cs;
|
result += cs;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -372,15 +372,15 @@ class serializer
|
||||||
{
|
{
|
||||||
if (codepoint <= 0xFFFF)
|
if (codepoint <= 0xFFFF)
|
||||||
{
|
{
|
||||||
std::snprintf(string_buffer.data() + bytes, 7, "\\u%04x",
|
(std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x",
|
||||||
static_cast<uint16_t>(codepoint));
|
static_cast<uint16_t>(codepoint));
|
||||||
bytes += 6;
|
bytes += 6;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::snprintf(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x",
|
(std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x",
|
||||||
static_cast<uint16_t>(0xD7C0 + (codepoint >> 10)),
|
static_cast<uint16_t>(0xD7C0 + (codepoint >> 10)),
|
||||||
static_cast<uint16_t>(0xDC00 + (codepoint & 0x3FF)));
|
static_cast<uint16_t>(0xDC00 + (codepoint & 0x3FF)));
|
||||||
bytes += 12;
|
bytes += 12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,7 +416,7 @@ class serializer
|
||||||
case error_handler_t::strict:
|
case error_handler_t::strict:
|
||||||
{
|
{
|
||||||
std::string sn(3, '\0');
|
std::string sn(3, '\0');
|
||||||
snprintf(&sn[0], sn.size(), "%.2X", byte);
|
(std::snprintf)(&sn[0], sn.size(), "%.2X", byte);
|
||||||
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn));
|
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ class serializer
|
||||||
case error_handler_t::strict:
|
case error_handler_t::strict:
|
||||||
{
|
{
|
||||||
std::string sn(3, '\0');
|
std::string sn(3, '\0');
|
||||||
snprintf(&sn[0], sn.size(), "%.2X", static_cast<uint8_t>(s.back()));
|
(std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<uint8_t>(s.back()));
|
||||||
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
|
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ class serializer
|
||||||
static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
|
static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
|
||||||
|
|
||||||
// the actual conversion
|
// the actual conversion
|
||||||
std::ptrdiff_t len = snprintf(number_buffer.data(), number_buffer.size(), "%.*g", d, x);
|
std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x);
|
||||||
|
|
||||||
// negative value indicates an error
|
// negative value indicates an error
|
||||||
assert(len > 0);
|
assert(len > 0);
|
||||||
|
|
|
@ -3812,7 +3812,7 @@ scan_number_done:
|
||||||
{
|
{
|
||||||
// escape control characters
|
// escape control characters
|
||||||
char cs[9];
|
char cs[9];
|
||||||
snprintf(cs, 9, "<U+%.4X>", static_cast<unsigned char>(c));
|
(std::snprintf)(cs, 9, "<U+%.4X>", static_cast<unsigned char>(c));
|
||||||
result += cs;
|
result += cs;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -6605,7 +6605,7 @@ class binary_reader
|
||||||
default: // anything else not supported (yet)
|
default: // anything else not supported (yet)
|
||||||
{
|
{
|
||||||
char cr[3];
|
char cr[3];
|
||||||
snprintf(cr, sizeof(cr), "%.2hhX", static_cast<unsigned char>(element_type));
|
(std::snprintf)(cr, sizeof(cr), "%.2hhX", static_cast<unsigned char>(element_type));
|
||||||
return sax->parse_error(element_type_parse_position, std::string(cr), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr)));
|
return sax->parse_error(element_type_parse_position, std::string(cr), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8262,7 +8262,7 @@ class binary_reader
|
||||||
std::string get_token_string() const
|
std::string get_token_string() const
|
||||||
{
|
{
|
||||||
char cr[3];
|
char cr[3];
|
||||||
snprintf(cr, 3, "%.2hhX", static_cast<unsigned char>(current));
|
(std::snprintf)(cr, 3, "%.2hhX", static_cast<unsigned char>(current));
|
||||||
return std::string{cr};
|
return std::string{cr};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11143,15 +11143,15 @@ class serializer
|
||||||
{
|
{
|
||||||
if (codepoint <= 0xFFFF)
|
if (codepoint <= 0xFFFF)
|
||||||
{
|
{
|
||||||
std::snprintf(string_buffer.data() + bytes, 7, "\\u%04x",
|
(std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x",
|
||||||
static_cast<uint16_t>(codepoint));
|
static_cast<uint16_t>(codepoint));
|
||||||
bytes += 6;
|
bytes += 6;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::snprintf(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x",
|
(std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x",
|
||||||
static_cast<uint16_t>(0xD7C0 + (codepoint >> 10)),
|
static_cast<uint16_t>(0xD7C0 + (codepoint >> 10)),
|
||||||
static_cast<uint16_t>(0xDC00 + (codepoint & 0x3FF)));
|
static_cast<uint16_t>(0xDC00 + (codepoint & 0x3FF)));
|
||||||
bytes += 12;
|
bytes += 12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11187,7 +11187,7 @@ class serializer
|
||||||
case error_handler_t::strict:
|
case error_handler_t::strict:
|
||||||
{
|
{
|
||||||
std::string sn(3, '\0');
|
std::string sn(3, '\0');
|
||||||
snprintf(&sn[0], sn.size(), "%.2X", byte);
|
(std::snprintf)(&sn[0], sn.size(), "%.2X", byte);
|
||||||
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn));
|
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11268,7 +11268,7 @@ class serializer
|
||||||
case error_handler_t::strict:
|
case error_handler_t::strict:
|
||||||
{
|
{
|
||||||
std::string sn(3, '\0');
|
std::string sn(3, '\0');
|
||||||
snprintf(&sn[0], sn.size(), "%.2X", static_cast<uint8_t>(s.back()));
|
(std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<uint8_t>(s.back()));
|
||||||
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
|
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11387,7 +11387,7 @@ class serializer
|
||||||
static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
|
static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
|
||||||
|
|
||||||
// the actual conversion
|
// the actual conversion
|
||||||
std::ptrdiff_t len = snprintf(number_buffer.data(), number_buffer.size(), "%.*g", d, x);
|
std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x);
|
||||||
|
|
||||||
// negative value indicates an error
|
// negative value indicates an error
|
||||||
assert(len > 0);
|
assert(len > 0);
|
||||||
|
|
Loading…
Reference in a new issue