diff options
author | Hossein <hossein@libreoffice.org> | 2022-02-10 23:36:15 +0100 |
---|---|---|
committer | Hossein <hossein@libreoffice.org> | 2022-03-01 11:40:15 +0100 |
commit | acc008c6600070837599c994e5552e66ec85c18c (patch) | |
tree | d101a53b9c7ebcf05c45939a23a2eff54f158c2b | |
parent | fc8e5f91fcf3a63d6bcd29c498e58a67e9abe67f (diff) |
Add asserts to make sure the calculation is correct
On Linux/gcc (Ubuntu 10.3.0-1ubuntu1~20.04), I was getting this
warning:
sc/source/core/data/bcaslot.cxx:647:25: warning: comparison of
unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
647 | assert(slot >= 0 && slot < mnBcaSlots);
| ~~~~~^~~~
slot variable is of type SCSIZE, which is defined as size_t in
sc/inc/address.hxx.
This is fixed in 405a7a09558ad17642808cc3739ab202f86bea0c. To make
sure the calculation of slot is OK, I have added these 2 asserts:
assert(nRow >= rSD.nStartRow);
assert(nCol >= rSD.nStartCol);
Change-Id: I731c1b6e913febde51fc16042d32c35950e707db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129805
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
-rw-r--r-- | sc/source/core/data/bcaslot.cxx | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index 65bc2600d475..09493963469c 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -639,6 +639,8 @@ inline SCSIZE ScBroadcastAreaSlotMachine::ComputeSlotOffset( { if (nRow < rSD.nStopRow && nCol < rSD.nStopCol) { + assert(nRow >= rSD.nStartRow); + assert(nCol >= rSD.nStartCol); SCSIZE slot = rSD.nCumulatedRow + static_cast<SCSIZE>(nRow - rSD.nStartRow) / rSD.nSliceRow + rSD.nCumulatedCol |