Re: [PATCH] iommu: Convert unreachable() to BUG()

From: Peter Zijlstra
Date: Thu Mar 27 2025 - 08:37:39 EST


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.

Compilers see this as a clue to just stop code-gen. Very bad behaviour
if you ever actually get there. BUG() at the very least stops the kernel
dead, instead of continuing to run random code that comes after.