> From: Scott Cheloha <[email protected]>
> Date: Fri, 25 Sep 2020 09:48:20 -0400
> 
> > On Sep 24, 2020, at 07:43, Theo de Raadt <[email protected]> wrote:
> > 
> > Mark Kettenis <[email protected]> wrote:
> > 
> >>> Date: Thu, 24 Sep 2020 11:53:59 +0200
> >>> From: Martin Pieuchot <[email protected]>
> >>> 
> >>> Convert various "if (x) panic()" idioms into "KASSERT(!x)".  The panic
> >>> message isn't helping for such sanity checks and this help reducing the
> >>> diff with NetBSD.
> >>> 
> >>> ok?
> >> 
> >> Yes, the KASSERTs are probably more useful for debugging.  The
> >> downside is that we lose the checks in RAMDISK kernels.  The upside of
> >> that is that it makes the kernel smaller.
> >> 
> >> ok kettenis@
> > 
> > That's the complete assessment of the situation, and on the scale I'm
> > happy with the diff.
> > 
> > ok deraadt
> 
> Is there any scenario where
> 
>         if (condition)
>                 panic();
> 
> is preferable to
> 
>         KASSERT(condition);
> 
> outside of function calls with side effects?

Apart from what deraadt@ already said, KASSERT() really should only be
used for "this really shouldn't happen" cases.  Whereas the panic can
be used for cases that can happen but we don't know how to (or don't
want to) handle.

And as I implied, KASSERTs are no-ops in RAMDISK kernels so they don't
stop things going horribly of the rails in that context, whereas a
panic would still happen.

Reply via email to