From: Adrian Ratiu Date: Fri, 20 Feb 2026 12:35:29 GMT Subject: Re: [PATCH v2 1/8] hook: add internal state alloc/free callbacks Message-ID: <87ldgny4mm.fsf@collabora.com> In-Reply-To: On Thu, 19 Feb 2026, Junio C Hamano wrote: > Adrian Ratiu writes: > >> + /* >> + * Ensure cb_data copy and free functions are either provided together, >> + * or neither one is provided. >> + */ >> + if ((options->feed_pipe_cb_data_alloc && !options->feed_pipe_cb_data_free) || >> + (!options->feed_pipe_cb_data_alloc && options->feed_pipe_cb_data_free)) >> + BUG("feed_pipe_cb_data_alloc and feed_pipe_cb_data_free must be set together"); > > A way to avoid being repetitious may be to say > > if (!!options->feed_pipe_cb_data_alloc != !!options->feed_pipe_cb_data_free) > > or > > if (!!options->feed_pipe_cb_data_alloc ^ !!options->feed_pipe_cb_data_free) > > but it (especially the latter) might be a bit too cute for some > people's taste. Thanks for suggesting this. I was actually thinking of ways to simplify this and the double negation didn't occur to me. Will do in v3.