Re: [PATCH v2 09/17] midx: return success/failure in chunk write methods

2 messages, 2 authors, 2021-02-05 · open the first message on its own page

Re: [PATCH v2 09/17] midx: return success/failure in chunk write methods

From: Junio C Hamano <hidden>
Date: 2021-02-04 23:00:25

"Derrick Stolee via GitGitGadget" [off-list ref] writes:
From: Derrick Stolee <redacted>

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.
OK, that makes sense.

In this step I see the same "f->total + f->offset" sprinkled in some
places, but they will all go away in the "midx: use chunk-format API
in write_midx_internal()" step, so it is not such a huge deal.

Thanks.

Re: [PATCH v2 09/17] midx: return success/failure in chunk write methods

From: Derrick Stolee <hidden>
Date: 2021-02-05 23:02:57

On 2/4/2021 5:59 PM, Junio C Hamano wrote:
"Derrick Stolee via GitGitGadget" [off-list ref] writes:
In this step I see the same "f->total + f->offset" sprinkled in some
places, but they will all go away in the "midx: use chunk-format API
in write_midx_internal()" step, so it is not such a huge deal.
I'll move the ones that are introduced by this patch, but others
already exist that also get removed by a later patch. I won't
touch those until they are deleted.

Thanks,
-Stolee
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help