зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1545970 - make sure we only divide or modular TimeUnit on unsigned int32. r=jya
The way we use `operator/` on TimeUnit is usaually to divide 2 for the fuzz or to divide the playback rate, and the rate is always a unsigned int. The `operator%` should also have same constraint, because there is meaningless to do such a operation on a negative value. Differential Revision: https://phabricator.services.mozilla.com/D37310 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a2577500f4
Коммит
ac67bcfa81
|
@ -178,11 +178,11 @@ class TimeUnit final {
|
|||
return TimeUnit::FromSeconds(ToSeconds() * aVal);
|
||||
}
|
||||
friend TimeUnit operator/(const TimeUnit& aUnit, int64_t aVal) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(INT32_MIN <= aVal && aVal <= INT32_MAX);
|
||||
MOZ_DIAGNOSTIC_ASSERT(0 <= aVal && aVal <= UINT32_MAX);
|
||||
return TimeUnit(aUnit.mValue / aVal);
|
||||
}
|
||||
friend TimeUnit operator%(const TimeUnit& aUnit, int64_t aVal) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(INT32_MIN <= aVal && aVal <= INT32_MAX);
|
||||
MOZ_DIAGNOSTIC_ASSERT(0 <= aVal && aVal <= UINT32_MAX);
|
||||
return TimeUnit(aUnit.mValue % aVal);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче