Re: [PATCH 01/11] midx.c: clean up chunkfile after reading the MIDX
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 21, 2021, 05:50 UTC
- Message-ID
- <xmqqfssvncyi.fsf@gitster.g>
- In-Reply-To
- <30f6f23daf49814f479865eea5f9ee68de209d5f.1634787555.git.me@ttaylorr.com>
Taylor Blau <me@ttaylorr.com> writes:
Show 25 quoted lines
> The patch contents are from Ævar, but the message is mine. I hope that
> he doesn't mind me forging his sign-off here.
>
> midx.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/midx.c b/midx.c
> index 8433086ac1..36e4754767 100644
> --- a/midx.c
> +++ b/midx.c
> @@ -179,12 +179,13 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local
> trace2_data_intmax("midx", the_repository, "load/num_packs", m->num_packs);
> trace2_data_intmax("midx", the_repository, "load/num_objects", m->num_objects);
>
> + free_chunkfile(cf);
> return m;
>
> cleanup_fail:
> free(m);
> free(midx_name);
> - free(cf);
> + free_chunkfile(cf);
> if (midx_map)
> munmap(midx_map, midx_size);
> if (0 <= fd)The former is not something we can mechanically locate, but the latter we should be able to. And indeed this is the only instance the following experiment finds.
$ cat >contrib/coccinelle/chunkfile.cocci <<-\EOF
@@
identifier f !~ "^free_chunkfile$";
struct chunkfile *cf;
@@
f(...) {<...
- free(cf)
+ free_chunkfile(cf)
...>}
EOF
$ make contrib/coccinelle/chunkfile.cocci.patchThanks.