AK: Avoid implicit conversion clang-tidy warnings in AK::Time

This commit is contained in:
Andrew Kaster 2021-10-31 14:57:54 -06:00 committed by Andreas Kling
parent 2c4f7fae1e
commit 2b16ee742e
Notes: sideshowbarker 2024-07-18 01:07:43 +09:00

View file

@ -115,9 +115,9 @@ private:
i64 numerator_64 = numerator; i64 numerator_64 = numerator;
i64 dividend = sane_mod(numerator_64, denominator); i64 dividend = sane_mod(numerator_64, denominator);
// Does not underflow: numerator can only become smaller. // Does not underflow: numerator can only become smaller.
numerator = numerator_64; numerator = static_cast<i32>(numerator_64);
// Does not overflow: Will be smaller than original value of 'numerator'. // Does not overflow: Will be smaller than original value of 'numerator'.
return dividend; return static_cast<i32>(dividend);
} }
public: public:
@ -139,9 +139,10 @@ public:
} }
[[nodiscard]] static Time from_timespec(const struct timespec&); [[nodiscard]] static Time from_timespec(const struct timespec&);
[[nodiscard]] static Time from_timeval(const struct timeval&); [[nodiscard]] static Time from_timeval(const struct timeval&);
[[nodiscard]] constexpr static Time min() { return Time(-0x8000'0000'0000'0000LL, 0); }; // We don't pull in <stdint.h> for the pretty min/max definitions because this file is also included in the Kernel
[[nodiscard]] constexpr static Time min() { return Time(-__INT64_MAX__ - 1LL, 0); };
[[nodiscard]] constexpr static Time zero() { return Time(0, 0); }; [[nodiscard]] constexpr static Time zero() { return Time(0, 0); };
[[nodiscard]] constexpr static Time max() { return Time(0x7fff'ffff'ffff'ffffLL, 999'999'999); }; [[nodiscard]] constexpr static Time max() { return Time(__INT64_MAX__, 999'999'999); };
#ifndef KERNEL #ifndef KERNEL
[[nodiscard]] static Time now_realtime(); [[nodiscard]] static Time now_realtime();