From 19647e083c0fb6889a0dcd1cf459bc99d46a4ab0 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 25 Oct 2018 14:27:55 +0200 Subject: [PATCH] :rotating_light: fixed compiler warnings --- include/nlohmann/detail/input/binary_reader.hpp | 4 ++-- include/nlohmann/detail/output/serializer.hpp | 1 + single_include/nlohmann/json.hpp | 5 +++-- test/src/fuzzer-parse_json.cpp | 4 ---- test/src/unit-bson.cpp | 6 +++--- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index 615ab73c..7d278736 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -246,13 +246,13 @@ class binary_reader case 0x10: // int32 { std::int32_t value; - return get_number(input_format_t::bson, value) and sax->number_integer(static_cast(value)); + return get_number(input_format_t::bson, value) and sax->number_integer(value); } case 0x12: // int64 { std::int64_t value; - return get_number(input_format_t::bson, value) and sax->number_integer(static_cast(value)); + return get_number(input_format_t::bson, value) and sax->number_integer(value); } default: // anything else not supported (yet) diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index 1d107ce0..8c48e36e 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -463,6 +463,7 @@ class serializer continue; } } + break; } default: // decode found yet incomplete multi-byte code point diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index c9060781..9bb67ff1 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -6547,13 +6547,13 @@ class binary_reader case 0x10: // int32 { std::int32_t value; - return get_number(input_format_t::bson, value) and sax->number_integer(static_cast(value)); + return get_number(input_format_t::bson, value) and sax->number_integer(value); } case 0x12: // int64 { std::int64_t value; - return get_number(input_format_t::bson, value) and sax->number_integer(static_cast(value)); + return get_number(input_format_t::bson, value) and sax->number_integer(value); } default: // anything else not supported (yet) @@ -11161,6 +11161,7 @@ class serializer continue; } } + break; } default: // decode found yet incomplete multi-byte code point diff --git a/test/src/fuzzer-parse_json.cpp b/test/src/fuzzer-parse_json.cpp index ed586385..7aa3dc21 100644 --- a/test/src/fuzzer-parse_json.cpp +++ b/test/src/fuzzer-parse_json.cpp @@ -60,10 +60,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) // parse errors are ok, because input may be random bytes } catch (const json::out_of_range&) - { - // parse errors are ok, because input may be random bytes - } - catch (const json::out_of_range&) { // out of range errors may happen if provided sizes are excessive } diff --git a/test/src/unit-bson.cpp b/test/src/unit-bson.cpp index 5a16aefd..aeb7b898 100644 --- a/test/src/unit-bson.cpp +++ b/test/src/unit-bson.cpp @@ -1013,7 +1013,7 @@ TEST_CASE("BSON numerical data") { "entry", i } }; - std::uint64_t iu = *reinterpret_cast(&i); + auto iu = i; std::vector expected_bson = { 0x10u, 0x00u, 0x00u, 0x00u, // size (little endian) @@ -1068,7 +1068,7 @@ TEST_CASE("BSON numerical data") { "entry", i } }; - std::uint64_t iu = *reinterpret_cast(&i); + auto iu = i; std::vector expected_bson = { 0x14u, 0x00u, 0x00u, 0x00u, // size (little endian) @@ -1118,7 +1118,7 @@ TEST_CASE("BSON numerical data") { "entry", i } }; - std::uint64_t iu = *reinterpret_cast(&i); + auto iu = i; std::vector expected_bson = { 0x14u, 0x00u, 0x00u, 0x00u, // size (little endian)