Commit 3c553b49 authored by Xavier Deguillard's avatar Xavier Deguillard Committed by Facebook GitHub Bot

Explicitly cast to long in chrono::durationToPosixTime

Summary:
The MSVC compiler was complaining that an implicit conversion from intmax_t
to long was being performed. Let's use static_cast to silence it.

Reviewed By: simpkins

Differential Revision: D21267752

fbshipit-source-id: e466f107ca8e861c12e0abd1f8fa7448f22adfd9
parent 81b08b7e
...@@ -138,7 +138,8 @@ static Expected<std::pair<time_t, long>, ConversionCode> durationToPosixTime( ...@@ -138,7 +138,8 @@ static Expected<std::pair<time_t, long>, ConversionCode> durationToPosixTime(
auto secTimeT = static_cast<time_t>(sec.value()); auto secTimeT = static_cast<time_t>(sec.value());
auto remainder = duration.count() - (secTimeT * Denominator); auto remainder = duration.count() - (secTimeT * Denominator);
long subsec = (remainder * SubsecondRatio::den) / Denominator; long subsec =
static_cast<long>((remainder * SubsecondRatio::den) / Denominator);
if (UNLIKELY(duration.count() < 0) && remainder != 0) { if (UNLIKELY(duration.count() < 0) && remainder != 0) {
if (secTimeT == std::numeric_limits<time_t>::lowest()) { if (secTimeT == std::numeric_limits<time_t>::lowest()) {
return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW); return makeUnexpected(ConversionCode::NEGATIVE_OVERFLOW);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment