mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-31 06:48:22 -04:00
strat: minor result/overflow check fixes
This commit is contained in:
parent
e13b81aa9e
commit
741efd04ec
3 changed files with 11 additions and 19 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue