Re: [PATCH v4 04/16] ref-filter: add `ref_filter_clear()`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 20, 2023 at 10:21:16AM -0400, Taylor Blau wrote:

> From: Jeff King <peff@xxxxxxxx>
> 
> We did not bother to clean up at all in `git branch` or `git tag`, and
> `git for-each-ref` only cleans up a couple of members.
> 
> Add and call `ref_filter_clear()` when cleaning up a `struct
> ref_filter`. Running this patch (without any test changes) indicates a
> couple of now leak-free tests. This was found by running:
> 
>     $ make SANITIZE=leak
>     $ make -C t GIT_TEST_PASSING_SANITIZE_LEAK=check GIT_TEST_OPTS=--immediate
> 
> (Note that the `reachable_from` and `unreachable_from` lists should be
> cleaned as they are used. So this is just covering any case where we
> might bail before running the reachability check.)

And this is the one that benefits from the earlier future-proofing. :)

(In case anyone is wondering why I am reviewing my own commits, it's
because Taylor and I worked on this topic together off-list, but he
wrote the commit messages after I dumped a bunch of cleanups on him).

> +void ref_filter_init(struct ref_filter *filter)
> +{
> +	struct ref_filter blank = REF_FILTER_INIT;
> +	memcpy(filter, &blank, sizeof(blank));
> +}

I was a little surprised by adding init() here, but we need it at the
end of clear(). So this is an OK place for it (the other option would be
in the earlier INIT patch, but it would be unused until now).

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux