diff --git a/system_wrappers/include/ntp_time.h b/system_wrappers/include/ntp_time.h index 1f57558b71..332f8f4624 100644 --- a/system_wrappers/include/ntp_time.h +++ b/system_wrappers/include/ntp_time.h @@ -70,11 +70,15 @@ inline int64_t Int64MsToQ32x32(int64_t milliseconds) { double result = std::round(milliseconds * (NtpTime::kFractionsPerSecond / 1000.0)); - if (result <= std::numeric_limits::min()) { + // Explicitly cast values to double to avoid implicit conversion warnings + // The conversion of the std::numeric_limits::max() triggers + // -Wimplicit-int-float-conversion warning in clang 10.0.0 without explicit + // cast + if (result <= static_cast(std::numeric_limits::min())) { return std::numeric_limits::min(); } - if (result >= std::numeric_limits::max()) { + if (result >= static_cast(std::numeric_limits::max())) { return std::numeric_limits::max(); } @@ -89,11 +93,15 @@ inline uint64_t Int64MsToUQ32x32(int64_t milliseconds) { double result = std::round(milliseconds * (NtpTime::kFractionsPerSecond / 1000.0)); - if (result <= std::numeric_limits::min()) { + // Explicitly cast values to double to avoid implicit conversion warnings + // The conversion of the std::numeric_limits::max() triggers + // -Wimplicit-int-float-conversion warning in clang 10.0.0 without explicit + // cast + if (result <= static_cast(std::numeric_limits::min())) { return std::numeric_limits::min(); } - if (result >= std::numeric_limits::max()) { + if (result >= static_cast(std::numeric_limits::max())) { return std::numeric_limits::max(); }