]> git.ipfire.org Git - thirdparty/git.git/commit
midx-write: simplify error cases
authorDerrick Stolee <stolee@gmail.com>
Fri, 5 Sep 2025 19:26:18 +0000 (19:26 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Sep 2025 19:32:01 +0000 (12:32 -0700)
commitc25651aefdf583ebb2dbb88437337947372de8f3
tree8c50f592383a41531fd6ead5b51aa5d2097cc51c
parent1f2bc6be1dbbda5bc40a23bd58a60bbee9de7401
midx-write: simplify error cases

The write_midx_internal() method uses gotos to jump to a cleanup section to
clear memory before returning 'result'. Since these jumps are more common
for error conditions, initialize 'result' to -1 and then only set it to 0
before returning with success. There are a couple places where we return
with success via a jump.

This has the added benefit that the method now returns -1 on error instead
of an inconsistent 1 or -1.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
midx-write.c