strat: minor result/overflow check fixes

This commit is contained in:
Michael Scire 2022-03-13 03:30:17 -07:00 committed by SciresM
parent e13b81aa9e
commit 741efd04ec
3 changed files with 11 additions and 19 deletions

View file

@ -157,11 +157,7 @@ namespace ams::time::impl::util {
R_UNLESS(out != nullptr, time::ResultInvalidPointer());
R_UNLESS(from.source_id == to.source_id, time::ResultNotComparable());
const bool no_overflow = (from.value >= 0 ? (to.value >= std::numeric_limits<s64>::min() + from.value)
: (to.value <= std::numeric_limits<s64>::max() + from.value));
R_UNLESS(no_overflow, time::ResultOverflowed());
*out = to.value - from.value;
R_UNLESS(ams::util::TrySubtractWithoutOverflow(out, to.value, from.value), time::ResultOverflowed());
return ResultSuccess();
}