fsmonitor: de-duplicate BUG()s around dirty bits
authorDerrick Stolee <redacted>
Sat, 23 Jan 2021 19:58:14 +0000 (19:58 +0000)
committerJunio C Hamano <redacted>
Sun, 24 Jan 2021 01:14:07 +0000 (17:14 -0800)
commitcae70acf2431f0c31e5c097b96fa5bd752526e6d
treeb76cd1aeb458809f9f824f540c26a6ab561e6f61
parentc80dd3967f28527dab49c8e9525524c7f33baa22
fsmonitor: de-duplicate BUG()s around dirty bits

The index has an fsmonitor_dirty bitmap that records which index entries
are "dirty" based on the response from the FSMonitor. If this bitmap
ever grows larger than the index, then there was an error in how it was
constructed, and it was probably a developer's bug.

There are several BUG() statements that are very similar, so replace
these uses with a simpler assert_index_minimum(). Since there is one
caller that uses a custom 'pos' value instead of the bit_size member, we
cannot simplify it too much. However, the error string is identical in
each, so this simplifies things.

Be sure to add one when checking if a position if valid, since the
minimum is a bound on the expected size.

The end result is that the code is simpler to read while also preserving
these assertions for developers in the FSMonitor space.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
fsmonitor.c
git clone https://git.99rst.org/PROJECT