From 2b16ee742e88d589a307963e8eeb3413abd82c35 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sun, 31 Oct 2021 14:57:54 -0600 Subject: [PATCH] AK: Avoid implicit conversion clang-tidy warnings in AK::Time --- AK/Time.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/AK/Time.h b/AK/Time.h index 29fb458e31..806bc160af 100644 --- a/AK/Time.h +++ b/AK/Time.h @@ -115,9 +115,9 @@ private: i64 numerator_64 = numerator; i64 dividend = sane_mod(numerator_64, denominator); // Does not underflow: numerator can only become smaller. - numerator = numerator_64; + numerator = static_cast(numerator_64); // Does not overflow: Will be smaller than original value of 'numerator'. - return dividend; + return static_cast(dividend); } public: @@ -139,9 +139,10 @@ public: } [[nodiscard]] static Time from_timespec(const struct timespec&); [[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 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 max() { return Time(0x7fff'ffff'ffff'ffffLL, 999'999'999); }; + [[nodiscard]] constexpr static Time max() { return Time(__INT64_MAX__, 999'999'999); }; #ifndef KERNEL [[nodiscard]] static Time now_realtime();