midx: return success/failure in chunk write methods
authorDerrick Stolee <redacted>
Thu, 18 Feb 2021 14:07:31 +0000 (14:07 +0000)
committerJunio C Hamano <redacted>
Thu, 18 Feb 2021 21:38:16 +0000 (13:38 -0800)
commit0ccd713cb6c4dafd36bdf85384becbb9b38504ba
treef187b54c2c7cf57fd3f65d3a1d81319ff6d6efb3
parent980f525c3cee7e272136eeb6e988a66f5f8a0bd8
midx: return success/failure in chunk write methods

Historically, the chunk-writing methods in midx.c have returned the
amount of data written so the writer method could compare this with the
table of contents. This presents with some interesting issues:

1. If a chunk writing method has a bug that miscalculates the written
   bytes, then we can satisfy the table of contents without actually
   writing the right amount of data to the hashfile. The commit-graph
   writing code checks the hashfile struct directly for a more robust
   verification.

2. There is no way for a chunk writing method to gracefully fail.
   Returning an int presents an opportunity to fail without a die().

3. The current pattern doesn't match chunk_write_fn type exactly, so we
   cannot share code with commit-graph.c

For these reasons, convert the midx chunk writer methods to return an
'int'. Since none of them fail at the moment, they all return 0.

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