From 8103f57fbe8c25f9f431ce262e75994700a44388 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Sat, 12 Oct 2024 13:10:16 +0200 Subject: [PATCH] Handle remaining clang-tidy issues --- .github/workflows/wide_decimal.yml | 4 ++-- math/wide_decimal/decwide_t.h | 36 +++++++++++++++++------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.github/workflows/wide_decimal.yml b/.github/workflows/wide_decimal.yml index f2d0493..962d361 100644 --- a/.github/workflows/wide_decimal.yml +++ b/.github/workflows/wide_decimal.yml @@ -84,8 +84,8 @@ jobs: echo "make prepare -f make_tidy_01_generic.gmk MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}" echo make prepare -f make_tidy_01_generic.gmk MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }} - echo "make tidy -f make_tidy_01_generic.gmk --jobs=8 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}" - make tidy -f make_tidy_01_generic.gmk --jobs=8 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }} + echo "make tidy -f make_tidy_01_generic.gmk --jobs=12 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}" + make tidy -f make_tidy_01_generic.gmk --jobs=12 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }} echo echo "verify empty word count of ./tmp/all.tidy_txt" wc ./tmp/all.tidy_txt | grep '0 0 0' diff --git a/math/wide_decimal/decwide_t.h b/math/wide_decimal/decwide_t.h index 88195a2..472171c 100644 --- a/math/wide_decimal/decwide_t.h +++ b/math/wide_decimal/decwide_t.h @@ -4382,9 +4382,10 @@ using local_flags_type = std::ios::fmtflags; // Assess the format flags. - // Obtain the showpos flag. - const auto my_showpos = (static_cast(ostrm_flags & std::ios::showpos) != static_cast(UINT8_C(0))); - const auto my_uppercase = (static_cast(ostrm_flags & std::ios::uppercase) != static_cast(UINT8_C(0))); + + // Obtain the showpos and uppercase flags. + const bool my_showpos { static_cast(ostrm_flags & std::ios::showpos) == static_cast(std::ios::showpos) }; + const bool my_uppercase { static_cast(ostrm_flags & std::ios::uppercase) == static_cast(std::ios::uppercase) }; using std::ilogb; @@ -4396,7 +4397,7 @@ if (static_cast(ostrm_flags & std::ios::scientific) == static_cast(std::ios::scientific)) { my_float_field = detail::os_float_field_type::scientific; } else if(static_cast(ostrm_flags & std::ios::fixed) == static_cast(std::ios::fixed)) { my_float_field = detail::os_float_field_type::fixed; } - else { my_float_field = detail::os_float_field_type::none; } + else { my_float_field = detail::os_float_field_type::none; } // Get the output stream's precision and limit it to max_digits10. // Erroneous negative precision (theoretically impossible) will be @@ -4404,16 +4405,19 @@ // at zero. const auto prec_default = static_cast(INT8_C(6)); - auto os_precision = - static_cast - ( - ((ostrm_precision <= static_cast(0)) - ? ((my_float_field != detail::os_float_field_type::scientific) ? static_cast(prec_default) : static_cast(UINT8_C(0))) - : static_cast(ostrm_precision)) - ); + std::uint_fast32_t + os_precision + { + static_cast + ( + ((ostrm_precision <= static_cast(0)) + ? ((my_float_field != detail::os_float_field_type::scientific) ? static_cast(prec_default) : static_cast(UINT8_C(0))) + : static_cast(ostrm_precision)) + ) + }; - auto use_scientific = false; - auto use_fixed = false; + bool use_scientific { false }; + bool use_fixed { false }; if (my_float_field == detail::os_float_field_type::scientific) { use_scientific = true; } else if(my_float_field == detail::os_float_field_type::fixed) { use_fixed = true; } @@ -4502,9 +4506,9 @@ // Obtain additional format information. const bool my_showpoint - { - static_cast(ostrm_flags & std::ios::showpoint) == static_cast(std::ios::showpoint) - }; + { + static_cast(ostrm_flags & std::ios::showpoint) == static_cast(std::ios::showpoint) + }; // Write the output string in the desired format. if (my_float_field == detail::os_float_field_type::scientific) { wr_string_scientific(str, the_exp, os_precision, my_showpoint, my_uppercase); }