From 3393ce0478181f70bf14de8eaee8693fee3c5214 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 28 Jan 2021 21:53:18 +0100 Subject: [PATCH] :rotating_light: fix warnings --- include/nlohmann/detail/input/lexer.hpp | 2 +- include/nlohmann/detail/output/binary_writer.hpp | 2 +- include/nlohmann/json.hpp | 10 +++++----- single_include/nlohmann/json.hpp | 2 +- test/src/unit-cbor.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 7c77af37e..8a8403a06 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -1447,7 +1447,7 @@ scan_number_done: { // escape control characters std::array cs{{}}; - (std::snprintf)(cs.data(), cs.size(), "", static_cast(c)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-varar) + (std::snprintf)(cs.data(), cs.size(), "", static_cast(c)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) result += cs.data(); } else diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index 2ff5c377e..c78420591 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1509,7 +1509,7 @@ class binary_writer void write_number(const NumberType n) { // step 1: write number to array of length NumberType - std::array vec; + std::array vec{}; std::memcpy(vec.data(), &n, sizeof(NumberType)); // step 2: write array to output (with possible reordering) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 8b63a3fec..57cf9d578 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -5936,7 +5936,7 @@ class basic_json @since version 1.0.0 */ - void swap(array_t& other) + void swap(array_t& other) // NOLINT(bugprone-exception-escape) { // swap only works for arrays if (JSON_HEDLEY_LIKELY(is_array())) @@ -5969,7 +5969,7 @@ class basic_json @since version 1.0.0 */ - void swap(object_t& other) + void swap(object_t& other) // NOLINT(bugprone-exception-escape) { // swap only works for objects if (JSON_HEDLEY_LIKELY(is_object())) @@ -6002,7 +6002,7 @@ class basic_json @since version 1.0.0 */ - void swap(string_t& other) + void swap(string_t& other) // NOLINT(bugprone-exception-escape) { // swap only works for strings if (JSON_HEDLEY_LIKELY(is_string())) @@ -6035,7 +6035,7 @@ class basic_json @since version 3.8.0 */ - void swap(binary_t& other) + void swap(binary_t& other) // NOLINT(bugprone-exception-escape) { // swap only works for strings if (JSON_HEDLEY_LIKELY(is_binary())) @@ -6049,7 +6049,7 @@ class basic_json } /// @copydoc swap(binary_t&) - void swap(typename binary_t::container_type& other) + void swap(typename binary_t::container_type& other) // NOLINT(bugprone-exception-escape) { // swap only works for strings if (JSON_HEDLEY_LIKELY(is_binary())) diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 49e6d017a..f8f8d52b3 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -7436,7 +7436,7 @@ scan_number_done: { // escape control characters std::array cs{{}}; - (std::snprintf)(cs.data(), cs.size(), "", static_cast(c)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-varar) + (std::snprintf)(cs.data(), cs.size(), "", static_cast(c)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) result += cs.data(); } else diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index 00aafba65..4c8f311d4 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -611,7 +611,7 @@ TEST_CASE("CBOR") SECTION("-32768..-129 (int 16)") { - for (int16_t i = -32768; i <= -129; ++i) + for (int16_t i = -32768; i <= int16_t(-129); ++i) { CAPTURE(i)