From ae29a0dbe53cf575dfa679336da92962e1482cf1 Mon Sep 17 00:00:00 2001 From: IRainman Date: Fri, 7 Mar 2025 20:39:20 +0300 Subject: [PATCH] PVS-Studio founds some errors, I fixed it. --- include/fast_float/ascii_number.h | 4 ++-- include/fast_float/decimal_to_binary.h | 6 +++--- include/fast_float/fast_float.h | 2 +- include/fast_float/float_common.h | 4 ++-- include/fast_float/parse_number.h | 18 +++++++++--------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/fast_float/ascii_number.h b/include/fast_float/ascii_number.h index a17e035..c5b93f4 100644 --- a/include/fast_float/ascii_number.h +++ b/include/fast_float/ascii_number.h @@ -286,7 +286,7 @@ report_parse_error(UC const *p, parse_error error) noexcept { template fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t parse_number_string(UC const *p, UC const *pend, - const parse_options_t options) noexcept { + parse_options_t const &options) noexcept { parsed_number_string_t answer; answer.valid = false; @@ -487,7 +487,7 @@ parse_number_string(UC const *p, UC const *pend, template fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t parse_int_string(UC const *p, UC const *pend, T &value, - parse_options_t options) { + parse_options_t const &options) noexcept { from_chars_result_t answer; diff --git a/include/fast_float/decimal_to_binary.h b/include/fast_float/decimal_to_binary.h index 94d0a00..028fbdc 100644 --- a/include/fast_float/decimal_to_binary.h +++ b/include/fast_float/decimal_to_binary.h @@ -103,15 +103,15 @@ fastfloat_really_inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept { adjusted_mantissa answer; if ((w == 0) || (q < binary::smallest_power_of_ten())) { - answer.power2 = 0; - answer.mantissa = 0; + // answer.power2 = 0; already set + // answer.mantissa = 0; already set // result should be zero return answer; } if (q > binary::largest_power_of_ten()) { // we want to get infinity: answer.power2 = binary::infinite_power(); - answer.mantissa = 0; + // answer.mantissa = 0; already set return answer; } // At this point in time q is in [powers::smallest_power_of_five, diff --git a/include/fast_float/fast_float.h b/include/fast_float/fast_float.h index af65c96..8dfef02 100644 --- a/include/fast_float/fast_float.h +++ b/include/fast_float/fast_float.h @@ -43,7 +43,7 @@ from_chars(UC const *first, UC const *last, T &value, template FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars_advanced(UC const *first, UC const *last, T &value, - parse_options_t options) noexcept; + parse_options_t const &options) noexcept; /** * from_chars for integer types. diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index d2ad2dd..28c55f7 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -1006,9 +1006,9 @@ template fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void to_float( #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN - const bool negative, + bool const negative, #endif - const adjusted_mantissa am, T &value) noexcept { + adjusted_mantissa const &am, T &value) noexcept { using equiv_uint = equiv_uint_t; equiv_uint word = equiv_uint(am.mantissa); word = equiv_uint(word | equiv_uint(am.power2) diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 47f04e8..017cc9c 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -145,7 +145,7 @@ template struct from_chars_caller { template FASTFLOAT_CONSTEXPR20 static from_chars_result_t call(UC const *first, UC const *last, T &value, - parse_options_t options) noexcept { + parse_options_t const &options) noexcept { return from_chars_advanced(first, last, value, options); } }; @@ -155,7 +155,7 @@ template <> struct from_chars_caller { template FASTFLOAT_CONSTEXPR20 static from_chars_result_t call(UC const *first, UC const *last, std::float32_t &value, - parse_options_t options) noexcept { + parse_options_t const &options) noexcept { // if std::float32_t is defined, and we are in C++23 mode; macro set for // float32; set value to float due to equivalence between float and // float32_t @@ -172,7 +172,7 @@ template <> struct from_chars_caller { template FASTFLOAT_CONSTEXPR20 static from_chars_result_t call(UC const *first, UC const *last, std::float64_t &value, - parse_options_t options) noexcept { + parse_options_t const &options) noexcept { // if std::float64_t is defined, and we are in C++23 mode; macro set for // float64; set value as double due to equivalence between double and // float64_t @@ -199,7 +199,7 @@ from_chars(UC const *first, UC const *last, T &value, */ template FASTFLOAT_CONSTEXPR20 from_chars_result_t -from_chars_advanced(const parsed_number_string_t &pns, T &value) noexcept { +from_chars_advanced(parsed_number_string_t const &pns, T &value) noexcept { static_assert(is_supported_float_type::value, "only some floating-point types are supported"); @@ -300,7 +300,7 @@ from_chars_advanced(const parsed_number_string_t &pns, T &value) noexcept { template FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars_float_advanced(UC const *first, UC const *last, T &value, - const parse_options_t options) noexcept { + parse_options_t const &options) noexcept { static_assert(is_supported_float_type::value, "only some floating-point types are supported"); @@ -359,7 +359,7 @@ from_chars(UC const *first, UC const *last, T &value, int base) noexcept { template FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars_int_advanced(UC const *first, UC const *last, T &value, - const parse_options_t options) noexcept { + parse_options_t const &options) noexcept { static_assert(is_supported_integer_type::value, "only integer types are supported"); @@ -398,7 +398,7 @@ template <> struct from_chars_advanced_caller<1> { template FASTFLOAT_CONSTEXPR20 static from_chars_result_t call(UC const *first, UC const *last, T &value, - const parse_options_t options) noexcept { + parse_options_t const &options) noexcept { return from_chars_float_advanced(first, last, value, options); } }; @@ -407,7 +407,7 @@ template <> struct from_chars_advanced_caller<2> { template FASTFLOAT_CONSTEXPR20 static from_chars_result_t call(UC const *first, UC const *last, T &value, - const parse_options_t options) noexcept { + parse_options_t const &options) noexcept { return from_chars_int_advanced(first, last, value, options); } }; @@ -415,7 +415,7 @@ template <> struct from_chars_advanced_caller<2> { template FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars_advanced(UC const *first, UC const *last, T &value, - const parse_options_t options) noexcept { + parse_options_t const &options) noexcept { return from_chars_advanced_caller< size_t(is_supported_float_type::value) + 2 * size_t(is_supported_integer_type::value)>::call(first, last, value,