From: Joe Perches <joe@perches.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Tejun Heo <htejun@gmail.com>,
Louis Langholtz <lou_langholtz@me.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
trivial@kernel.org, Rusty Russell <rusty@rustcorp.com.au>
Subject: [PATCH] checkpatch: Warn on BUG and BUG_ON uses
Date: Sun, 07 Jun 2015 22:44:01 -0700 [thread overview]
Message-ID: <1433742241.2742.4.camel@perches.com> (raw)
In-Reply-To: <CA+55aFwmOGaP1DN3frkfP+Df=jCwURqO22A6-5GqpMnZXkvMXA@mail.gmail.com>
Spake Linus:
> Hell no.
>
> Stop with the random BUG_ON() additions.
>
> I have said this before, and apparently I need to sat this again, and
> probably I will have to say it in the future.
>
> We don't add BUG_ON's for random reasons.
>
> The *ONLY* acceptable reason for a BUG_ON() is if the machine is dead
> anyway because of some major internal corruption.
>
> We have too many BUG_ON's. We've had people add BUG_ON's because "this
> cannot happen", and then it turns out they were wrong, and they just
> killed the machine.
>
> Dammit, there's no reason to add a BUG_ON() here in the first place,
> and the reason of "but but it's an unused error return": is f*cking
> retarded.
>
> Stop this idiocy. We don't write crap code just to satisfy some random
> coding standard or shut up a compiler error.
>
> At most, it could be a "WARN_ON_ONCE()". Maybe even just silently
> ignore the error. But BUG_ON()? Hell no.
>
> NO NO NO.
>
> Quite frankly, if you want to add error handling, then dammit, add it
> right. And no, BUG_ON() is _never_ proper error handling.
>
> BUG_ON() is for things like "uhhuh, somebody is trying to free a page
> that is already free". That is some serious internal corruption.
>
> BUG_ON() is _not_ for "I'm not doing any error handling, so I'll
> sprinkle random lines of BUG_ON() like fairy dust to make the compiler
> happen".
>
> Really. I'm getting very tired indeed of people adding BUG_ON's like
> that. Stop it.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 69c4716..f3daa4e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3423,12 +3423,11 @@ sub process {
}
}
-# # no BUG() or BUG_ON()
-# if ($line =~ /\b(BUG|BUG_ON)\b/) {
-# print "Try to use WARN_ON & Recovery code rather than BUG() or BUG_ON()\n";
-# print "$herecurr";
-# $clean = 0;
-# }
+# avoid BUG() or BUG_ON()
+ if ($line =~ /\b(BUG|BUG_ON)\b/) {
+ WARN("BUG",
+ "Avoid using $1 unless there is a serious corruption - try to use WARN_ON & recovery code instead\n" . $herecurr);
+ }
if ($line =~ /\bLINUX_VERSION_CODE\b/) {
WARN("LINUX_VERSION_CODE",
next prev parent reply other threads:[~2015-06-08 5:44 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <http://marc.info/?l=linux-kernel&m=143351431301630>
2015-06-07 23:54 ` [PATCH] kernel/params.c: make use of unused but set variable Louis Langholtz
2015-06-08 0:00 ` Tejun Heo
2015-06-08 0:17 ` Linus Torvalds
2015-06-08 0:58 ` Tejun Heo
2015-06-08 5:24 ` [PATCH v2] " Louis Langholtz
2015-06-10 17:05 ` [PATCH] " Louis Langholtz
2015-06-11 1:54 ` Tejun Heo
2015-06-12 3:17 ` Louis Langholtz
2015-06-08 5:44 ` Joe Perches [this message]
2015-06-08 5:46 ` Louis Langholtz
2015-06-08 7:12 ` [PATCH] debug: Deprecate BUG_ON() use in new code, introduce CRASH_ON() Ingo Molnar
2015-06-08 7:40 ` Alexander Holler
2015-06-08 8:08 ` Richard Weinberger
2015-06-08 8:42 ` Alexander Holler
2015-06-08 9:05 ` Ingo Molnar
2015-06-08 9:11 ` Ingo Molnar
2015-06-08 9:22 ` Alexander Holler
2015-06-08 11:29 ` Ingo Molnar
2015-06-08 9:16 ` Alexander Holler
2015-06-08 11:27 ` Ingo Molnar
2015-06-08 18:07 ` Alexander Holler
2015-06-08 19:35 ` Ingo Molnar
2015-06-09 1:07 ` Alexander Holler
2015-06-08 8:09 ` Ingo Molnar
2015-06-12 1:27 ` [PATCH] kernel/params.c: make use of unused but set variable Rusty Russell
2015-06-12 1:48 ` Tejun Heo
2015-06-14 19:49 ` Rusty Russell
2015-06-16 19:54 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433742241.2742.4.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=htejun@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lou_langholtz@me.com \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.org \
--cc=trivial@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox