diff options
author | Jeffrey Walton <noloader@gmail.com> | 2022-02-14 09:08:10 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2022-02-14 09:08:10 -0500 |
commit | c07c53ae418aae3e6c8938804d55221706d6c1e3 (patch) | |
tree | 4b294cac31eed5d5c78e48065d8f80d2acbe4290 /misc.h | |
parent | e06bac5bfcf4962aca14d6a7d67003d13ea70ba5 (diff) | |
download | cryptopp-git-c07c53ae418aae3e6c8938804d55221706d6c1e3.tar.gz |
Cleanup after merging PR #1043
Diffstat (limited to 'misc.h')
-rw-r--r-- | misc.h | 45 |
1 files changed, 2 insertions, 43 deletions
@@ -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 <class T, size_t SIZE = sizeof(T)>
-struct TruncatingMask;
-
-template <class T>
-struct TruncatingMask<T, 1>
-{
- T operator()()
- {
- return 0xFF;
- }
-};
-
-template <class T>
-struct TruncatingMask<T, 2>
-{
- T operator()()
- {
- return 0xFFFF;
- }
-};
-
-template <class T>
-struct TruncatingMask<T, 4>
-{
- T operator()()
- {
- return 0xFFFFFFFF;
- }
-};
-
-template <class T>
-struct TruncatingMask<T, 8>
-{
- 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<T2>()()) & 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
|