Subject: Re: [PATCH 1/5] usage.c: add a non-fatal bug() function to go with BUG()

From: Josh Steadmon <[email-masked]>
Date: Fri, 27 May 2022 10:03:30 -0700

On 2022.05.21 19:14, Ævar Arnfjörð Bjarmason wrote:
> Add a bug() function to use in cases where we'd like to indicate a
> runtime BUG(), but would like to deref the BUG() call because we're

Typo: I assume you meant s/deref/defer/

[snip]

> diff --git a/trace2.c b/trace2.c
> index e01cf77f1a8..d49d5d5a082 100644
> --- a/trace2.c
> +++ b/trace2.c
> @@ -211,6 +211,12 @@ int trace2_cmd_exit_fl(const char *file, int line, int code)
>  
>  	code &= 0xff;
>  
> +	if (bug_called_must_BUG) {
> +		/* BUG_vfl() calls exit(), which calls us again */
> +		bug_called_must_BUG = 0;
> +		BUG("had bug() output above, in addition missed BUG_if_bug() call");
> +	}
> +
>  	if (!trace2_enabled)
>  		return code;

While it does seem that trace2_cmd_exit_fl() is the only reasonable
place to put this cleanup code, perhaps it makes sense to rename this
function and move it out of trace2.c, to more clearly show that it has
multiple responsibilities now?