Re: [PATCH v2 2/6] usage.c: add a non-fatal bug() function to go with BUG()

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

 



Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes:

> +static void check_bug_if_BUG(void)
> +{
> +	if (!bug_called_must_BUG)
> +		return;
> +
> +	/* BUG_vfl() calls exit(), which calls us again */
> +	bug_called_must_BUG = 0;
> +	BUG("on exit(): had bug() call(s) in this process without explicit BUG_if_bug()");
> +}

Hm thinking out loud here, what if we set bug_called_must_BUG = 0 inside
of BUG()? Then we'd be guaranteed that BUG() will never infinitely
recurse.

Another benefit is that we can invoke bug() and follow up with BUG() to
unconditionally exit without a bogus warning "had bug() call(s) without
explicit BUG_if_bug()". This pattern could be useful for 6/6 [1], where
we no longer exit after printing the "BUG:" messages.

Just an idea :)

[1] https://lore.kernel.org/git/patch-v2-6.6-cbbe0276966-20220531T164806Z-avarab@xxxxxxxxx




[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