lkml.org 
[lkml]   [2021]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm: Use BUG_ON instead of if condition followed by BUG
On Wed, 24 Nov 2021 13:23:42 +0000 Matthew Wilcox <willy@infradead.org> wrote:

> On Wed, Nov 24, 2021 at 03:08:49AM +0000, cgel.zte@gmail.com wrote:
> > From: chiminghao <chi.minghao@zte.com.cn>
> >
> > Fix the following coccinelle report:
> > ./mm/memory_hotplug.c:2210:2-5:
> > WARNING Use BUG_ON instead of if condition followed by BUG.
>
> What coccinelle script is reporting this?
>
> > - if (try_remove_memory(start, size))
> > - BUG();
> > + BUG_ON(try_remove_memory(start, size));
>
> I really, really, really do not like this. For functions with
> side-effects, this is bad style. If it's a pure predicate, then
> sure, but this is bad.

I don't like it either. Yes, BUG() is special but it's such dangerous
practice. I'd vote to change coccinelle.

\
 
 \ /
  Last update: 2021-11-24 23:28    [W:0.154 / U:0.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site