Address the cpplint findings of json_document images

The exponent of the overflow check is an std::int64_t instead of a long
(runtime/int).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-29 14:03:22 +02:00
parent 5a936a2ef3
commit 8d9088ab05
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -10,7 +10,7 @@
#include <array> // array
#include <cstddef> // size_t
#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
#include <cstdint> // int64_t, uint8_t, uint16_t, uint32_t, uint64_t
#include <cstring> // memcmp, memcpy
#include <limits> // numeric_limits
#include <string> // string
@@ -299,7 +299,7 @@ inline bool check_number(const node& n, const unsigned char* text)
frac_digits = static_cast<std::size_t>(p - f0);
is_float = true;
}
long exponent = 0;
std::int64_t exponent = 0;
if (p != e && (*p | 0x20u) == 'e')
{
++p;
@@ -332,7 +332,7 @@ inline bool check_number(const node& n, const unsigned char* text)
}
// parse() rejects floats that overflow; as there, only a number whose
// magnitude could reach 1e308 needs the conversion
if (static_cast<long>(int_digits) + exponent > 300)
if (static_cast<std::int64_t>(int_digits) + exponent > 300)
{
const auto v = float_value<double>(reinterpret_cast<const char*>(s), n); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
return v <= (std::numeric_limits<double>::max)() && v >= -(std::numeric_limits<double>::max)();
+3 -3
View File
@@ -3771,7 +3771,7 @@ NLOHMANN_JSON_NAMESPACE_END
#include <array> // array
#include <cstddef> // size_t
#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
#include <cstdint> // int64_t, uint8_t, uint16_t, uint32_t, uint64_t
#include <cstring> // memcmp, memcpy
#include <limits> // numeric_limits
#include <string> // string
@@ -4299,7 +4299,7 @@ inline bool check_number(const node& n, const unsigned char* text)
frac_digits = static_cast<std::size_t>(p - f0);
is_float = true;
}
long exponent = 0;
std::int64_t exponent = 0;
if (p != e && (*p | 0x20u) == 'e')
{
++p;
@@ -4332,7 +4332,7 @@ inline bool check_number(const node& n, const unsigned char* text)
}
// parse() rejects floats that overflow; as there, only a number whose
// magnitude could reach 1e308 needs the conversion
if (static_cast<long>(int_digits) + exponent > 300)
if (static_cast<std::int64_t>(int_digits) + exponent > 300)
{
const auto v = float_value<double>(reinterpret_cast<const char*>(s), n); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
return v <= (std::numeric_limits<double>::max)() && v >= -(std::numeric_limits<double>::max)();