mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge #12770: Use explicit casting in cuckoocache's compute_hashes(...) to clarify integer conversion
9142dfea81
Use explicit casting in cuckoocache's compute_hashes(...) to clarify integer conversion (practicalswift)
Pull request description:
Use explicit casting in cuckoocache's `compute_hashes(...)` to clarify integer conversion.
I discussed this code with the code's author @JeremyRubin who suggested patching it to avoid any confusion.
At least one static analyzer incorrectly warns about a shift past bitwidth (UB) here, so this patch will help avoid confusion for human reviewers and static analyzers alike :-)
Tree-SHA512: 0419ee31b422d2ffedbd1a100688ec0ff5b0c1690d6d92592f638ca8db07a21a9650cb467923108c6f14a38d2bf07d6e6c85d2d1d4b7da53ffe6919f94f32655
This commit is contained in:
commit
603975b96a
@ -242,14 +242,14 @@ private:
|
||||
*/
|
||||
inline std::array<uint32_t, 8> compute_hashes(const Element& e) const
|
||||
{
|
||||
return {{(uint32_t)((hash_function.template operator()<0>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)((hash_function.template operator()<1>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)((hash_function.template operator()<2>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)((hash_function.template operator()<3>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)((hash_function.template operator()<4>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)((hash_function.template operator()<5>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)((hash_function.template operator()<6>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)((hash_function.template operator()<7>(e) * (uint64_t)size) >> 32)}};
|
||||
return {{(uint32_t)(((uint64_t)hash_function.template operator()<0>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)(((uint64_t)hash_function.template operator()<1>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)(((uint64_t)hash_function.template operator()<2>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)(((uint64_t)hash_function.template operator()<3>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)(((uint64_t)hash_function.template operator()<4>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)(((uint64_t)hash_function.template operator()<5>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)(((uint64_t)hash_function.template operator()<6>(e) * (uint64_t)size) >> 32),
|
||||
(uint32_t)(((uint64_t)hash_function.template operator()<7>(e) * (uint64_t)size) >> 32)}};
|
||||
}
|
||||
|
||||
/* end
|
||||
|
Loading…
Reference in New Issue
Block a user