mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-20 19:41:36 +00:00
Avoid possible division by zero
components/detournavigator/navmeshdb.cpp:183:43: warning: Division by zero [clang-analyzer-core.DivideZero] setMaxPageCount(*mDb, maxFileSize / dbPageSize + static_cast<std::uint64_t>((maxFileSize % dbPageSize) != 0)); ~~~~~~~~~~~~^~~~~~~~~~~~ components/detournavigator/navmeshdb.cpp:182:33: note: Calling 'getPageSize' const auto dbPageSize = getPageSize(*mDb); ^~~~~~~~~~~~~~~~~ components/detournavigator/navmeshdb.cpp:144:13: note: 'value' initialized to 0 std::uint64_t value = 0; ^~~~~~~~~~~~~~~~~~~ components/detournavigator/navmeshdb.cpp:145:13: note: Calling 'request<DetourNavigator::(anonymous namespace)::GetPageSize, unsigned long *, >' request(db, statement, &value, 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ components/sqlite3/request.hpp:254:64: note: Left side of '&&' is false for (std::size_t i = 0; executeStep(db, statement) && i < max; ++i) ^ components/detournavigator/navmeshdb.cpp:145:13: note: Returning from 'request<DetourNavigator::(anonymous namespace)::GetPageSize, unsigned long *, >' request(db, statement, &value, 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ components/detournavigator/navmeshdb.cpp:146:13: note: Returning zero (loaded from 'value') return value; ^~~~~~~~~~~~ components/detournavigator/navmeshdb.cpp:182:33: note: Returning from 'getPageSize' const auto dbPageSize = getPageSize(*mDb); ^~~~~~~~~~~~~~~~~ components/detournavigator/navmeshdb.cpp:182:9: note: 'dbPageSize' initialized to 0 const auto dbPageSize = getPageSize(*mDb); ^~~~~~~~~~~~~~~~~~~~~ components/detournavigator/navmeshdb.cpp:183:43: note: Division by zero setMaxPageCount(*mDb, maxFileSize / dbPageSize + static_cast<std::uint64_t>((maxFileSize % dbPageSize) != 0)); ~~~~~~~~~~~~^~~~~~~~~~~~
This commit is contained in:
parent
f1ded70366
commit
5b9ca3b979
1 changed files with 3 additions and 1 deletions
|
@ -179,7 +179,9 @@ namespace DetourNavigator
|
||||||
, mInsertShape(*mDb, DbQueries::InsertShape {})
|
, mInsertShape(*mDb, DbQueries::InsertShape {})
|
||||||
, mVacuum(*mDb, DbQueries::Vacuum {})
|
, mVacuum(*mDb, DbQueries::Vacuum {})
|
||||||
{
|
{
|
||||||
const auto dbPageSize = getPageSize(*mDb);
|
const std::uint64_t dbPageSize = getPageSize(*mDb);
|
||||||
|
if (dbPageSize == 0)
|
||||||
|
throw std::runtime_error("NavMeshDb page size is zero");
|
||||||
setMaxPageCount(*mDb, maxFileSize / dbPageSize + static_cast<std::uint64_t>((maxFileSize % dbPageSize) != 0));
|
setMaxPageCount(*mDb, maxFileSize / dbPageSize + static_cast<std::uint64_t>((maxFileSize % dbPageSize) != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue