cache-tree: simplify verify_cache() prototype
authorDerrick Stolee <redacted>
Sat, 23 Jan 2021 19:58:12 +0000 (19:58 +0000)
committerJunio C Hamano <redacted>
Sun, 24 Jan 2021 01:14:07 +0000 (17:14 -0800)
commit8d87e338e16e022545638a0e9a3e15c6bdb56111
tree3d02c87ba1f6d1f5f39965588f573cc3cc1ddc87
parentfb0882648e0d624f825974aa7030e56daf6de2af
cache-tree: simplify verify_cache() prototype

The verify_cache() method takes an array of cache entries and a count,
but these are always provided directly from a struct index_state. Use
a pointer to the full structure instead.

There is a subtle point when istate->cache_nr is zero that subtracting
one will underflow. This triggers a failure in t0000-basic.sh, among
others. Use "i + 1 < istate->cache_nr" to avoid these strange
comparisons. Convert i to be unsigned as well, which also removes the
potential signed overflow in the unlikely case that cache_nr is over 2.1
billion entries. The 'funny' variable has a maximum value of 11, so
making it unsigned does not change anything of importance.

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