From c07c53ae418aae3e6c8938804d55221706d6c1e3 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 14 Feb 2022 09:08:10 -0500 Subject: [PATCH] Cleanup after merging PR #1043 --- misc.h | 45 ++------------------------------------------- 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/misc.h b/misc.h index 1e818829..9cdf3aaa 100644 --- a/misc.h +++ b/misc.h @@ -1113,47 +1113,6 @@ inline T1 SaturatingSubtract1(const T1 &a, const T2 &b) return T1((a > b) ? (a - b) : 1); } -/// \brief Get the appropriate mask to do a truncating cast -template -struct TruncatingMask; - -template -struct TruncatingMask -{ - T operator()() - { - return 0xFF; - } -}; - -template -struct TruncatingMask -{ - T operator()() - { - return 0xFFFF; - } -}; - -template -struct TruncatingMask -{ - T operator()() - { - return 0xFFFFFFFF; - } -}; - -template -struct TruncatingMask -{ - T operator()() - { - return 0xFFFFFFFFFFFFFFFF; - } -}; - - /// \brief Reduces a value to a power of 2 /// \tparam T1 class or type /// \tparam T2 class or type @@ -1167,8 +1126,8 @@ inline T2 ModPowerOf2(const T1 &a, const T2 &b) { CRYPTOPP_ASSERT(IsPowerOf2(b)); // Coverity finding CID 170383 Overflowed return value (INTEGER_OVERFLOW) - // Visual studio runtime_checks don't like us truncating here with the cast to T2 TruncatingMask works around it - return T2(a & TruncatingMask()()) & SaturatingSubtract(b,1U); + // Visual Studio and /RTCc warning, https://docs.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks + return T2(a & SaturatingSubtract(b,1U)); } /// \brief Rounds a value down to a multiple of a second value