Re: [PATCH] iommu: Convert unreachable() to BUG()
From: Peter Zijlstra
Date: Wed Apr 02 2025 - 03:52:47 EST
On Tue, Apr 01, 2025 at 05:50:32PM -0700, Josh Poimboeuf wrote:
> On Thu, Mar 27, 2025 at 01:37:18PM +0100, Peter Zijlstra wrote:
> > On Wed, Mar 26, 2025 at 10:28:46PM -0700, Josh Poimboeuf wrote:
> > > Bare unreachable() should be avoided as it generates undefined behavior,
> > > e.g. falling through to the next function. Use BUG() instead so the
> > > error is defined.
> >
> > Right; I did a pass like this a while ago and thought I'd removed all
> > unreachable() abuse.
>
> Any reason not to just "#define unreachable() BUG()" and convert UD2 and
> similar to use __builtin_unreachable()?
Just remove unreachable() entirely at that point. But you're going to
have to update all the various arch code that does use it correctly :/
There are a few sites besides BUG() that need it; eg, long jumps when
bootstrapping etc.
But basically nothing outside of arch code should ever need or want
unreachable.