Bug 1410622 - Prevent warning on 64bit systems when comparing uint64_t with size_t max value. r=kats

MozReview-Commit-ID: 6X0AWEpVvYE

--HG--
extra : rebase_source : 4f9d9299c703b672ba2b4cb984f25ec182433e64
This commit is contained in:
Andi-Bogdan Postelnicu 2017-10-23 17:39:07 +03:00
Родитель de808e6708
Коммит bf6ef2620a
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -138,9 +138,12 @@ public:
int64_t tilesInFullRow = ((int64_t)mTileBounds.x2 - (int64_t)mTileBounds.x1) / kTileSize;
int64_t total = tilesInFirstRow + (tilesInFullRow * numberOfFullRows) + tilesInLastRow;
MOZ_ASSERT(total > 0);
// The total may be larger than what fits in a size_t, so clamp it to
// SIZE_MAX in that case.
return ((uint64_t)total > (uint64_t)SIZE_MAX) ? SIZE_MAX : (size_t)total;
// On 32bit systems the total may be larger than what fits in a size_t (4 bytes),
// so clamp it to size_t's max value in that case.
return static_cast<uint64_t>(total) >=
static_cast<uint64_t>(std::numeric_limits<size_t>::max())
? std::numeric_limits<size_t>::max()
: static_cast<size_t>(total);
}
// If aTileOrigin does not describe a tile inside our tile bounds, move it