]> git.hungrycats.org Git - bees/commit
extent scan: don't divide by zero if there were no loops
authorZygo Blaxell <bees@furryterror.org>
Fri, 14 Feb 2025 04:41:31 +0000 (23:41 -0500)
committerZygo Blaxell <bees@furryterror.org>
Fri, 14 Feb 2025 04:59:42 +0000 (23:59 -0500)
commita670aa5a711dd3fcbe4ef7ebc7e74426e178a6d9
tree5956d6f18ec1fcbfd6b42b30f5ad2a6be24f7da1
parent51b3bcdbe4e5f56ab281009d0abd11bd32c418dc
extent scan: don't divide by zero if there were no loops

Commit 183b6a5361e040d7cc70c3b3391f43e0d126bc33 ("extent scan: refactor
BeesCrawl, BeesScanMode*") moved some statistics calculations out of
the loop in `find_next_extent`, but did not ensure that the statistics
would not be calculated if the loop had not executed any iterations.

In rare instances, the function returns without entering the loop at all,
which results in divide by zero.  Add a check just before doing that.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees-roots.cc