aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNuno Goncalves <[email protected]>2019-10-20 09:42:45 +0200
committerNuno Goncalves <[email protected]>2019-10-20 10:31:55 +0200
commitb7dc5389d37be7ca6270b2645256e417e71572d8 (patch)
tree211142c4e9ff17797bd4c5557113162b280bc16f /src/lib
parenta79c2781066785a27f2e92c154d27a1c4f6efc5d (diff)
trick coverity by starting with sizeof-1
Signed-off-by: Nuno Goncalves <[email protected]>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/misc/roughtime/roughtime.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/misc/roughtime/roughtime.cpp b/src/lib/misc/roughtime/roughtime.cpp
index 6d3542160..516ef6078 100644
--- a/src/lib/misc/roughtime/roughtime.cpp
+++ b/src/lib/misc/roughtime/roughtime.cpp
@@ -34,16 +34,16 @@ template<class T, std::size_t N>
struct is_array<std::array<T,N>>:std::true_type{};
template<typename T>
-T impl_from_little_endian(const uint8_t* t, size_t i)
+T impl_from_little_endian(const uint8_t* t, const size_t i)
{
- static_assert(sizeof(T)<=sizeof(int64_t),"");
- return (i == 0) ? T(0) : (T(static_cast<int64_t>(t[i-1]) << ((i-1)*8)) + impl_from_little_endian<T>(t,i-1));
+ static_assert(sizeof(T) <= sizeof(int64_t), "");
+ return T(static_cast<int64_t>(t[i]) << i * 8) + (i == 0 ? T(0) : impl_from_little_endian<T>(t, i - 1));
}
template<typename T>
T from_little_endian(const uint8_t* t)
{
- return impl_from_little_endian<T>(t, sizeof(T));
+ return impl_from_little_endian<T>(t, sizeof(T) - 1);
}
template<typename T, enable_if_t<is_array<T>::value>* = nullptr>