strat: minor result/overflow check fixes
This commit is contained in:
1 parent
e13b81aa9e
commit
741efd04ec
3 files changed
+11
-19
No files matched your search
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user