Thread (9 messages) 9 messages, 6 authors, 2021-11-27

Re: [PATCH] mm: Use BUG_ON instead of if condition followed by BUG

From: Andrew Morton <akpm@linux-foundation.org>
Date: 2021-11-24 22:27:55
Also in: lkml

On Wed, 24 Nov 2021 13:23:42 +0000 Matthew Wilcox [off-list ref] wrote:
On Wed, Nov 24, 2021 at 03:08:49AM +0000, cgel.zte@gmail.com wrote:
quoted
From: chiminghao <redacted>

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?
quoted
-	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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help