All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Andy Whitcroft <apw@canonical.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Antonio SJ Musumeci <trapexit@spawn.link>,
	Miklos Szeredi <miklos@szeredi.hu>,
	Dave Jones <davej@codemonkey.org.uk>,
	Oleg Nesterov <oleg@redhat.com>,
	Dave Chinner <david@fromorbit.com>,
	Michal Hocko <mhocko@kernel.org>, Jan Kara <jack@suse.cz>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	stable <stable@vger.kernel.org>
Subject: [PATCH] checkpatch: extend BUG warning
Date: Wed, 05 Oct 2016 10:00:58 -0700	[thread overview]
Message-ID: <1475686858.6105.7.camel@perches.com> (raw)
In-Reply-To: <CA+55aFy2Kwud6N315zEK=0Jrh4GXc+ALZdqRONgOGcuy9feH9w@mail.gmail.com>

Include the prefixed and postfixed BUG/BUG_ON variants like VM_BUG_ON
that can kill the kernel.  Exclude the BUILD and lower case variants.

$ grep -rP --include=*.[ch] -oh "\w+_BUG_ON\w*" * | \
  sort | uniq -c | sort -rn
   1838 BUILD_BUG_ON
    632 snd_BUG_ON
    263 VM_BUG_ON_PAGE
    260 VM_BUG_ON
     97 GEM_BUG_ON
     57 SNIC_BUG_ON
     49 EFX_BUG_ON_PARANOID
     45 BUILD_BUG_ON_ZERO
     45 BUILD_BUG_ON_MSG
     30 B43legacy_BUG_ON
     24 VM_BUG_ON_VMA
     21 BUILD_BUG_ON_NOT_POWER_OF_2
     16 PCPU_SETUP_BUG_ON
     15 GLOCK_BUG_ON
     12 LOGFS_BUG_ON
     11 RWLOCK_BUG_ON
     10 VIRTUAL_BUG_ON
      9 SPIN_BUG_ON
      9 BUILD_BUG_ON_INVALID
      8 UNWINDER_BUG_ON
      8 DEBUG_SPINLOCK_BUG_ON
      7 VM_BUG_ON_MM
      7 LIST_BL_BUG_ON
      6 BUILD_BUG_ON_NULL
      5 MAYBE_BUILD_BUG_ON
      4 VM_BUG_ON_PGFLAGS
      4 SSB_BUG_ON
      4 HAVE_ARCH_BUG_ON
      4 BIO_BUG_ON
      3 DCCP_BUG_ON
      3 __BUILD_BUG_ON_NOT_POWER_OF_2
      2 __BUG_ON_cond
      2 __BUG_ON
      1 CONFIG_BUG_ON_DATA_CORRUPTION

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Joe Perches <joe@perches.com>
---
 scripts/checkpatch.pl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3373c65fef1c..be796704e218 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3725,8 +3725,9 @@ sub process {
 			}
 		}
 
-# avoid BUG() or BUG_ON()
-		if ($line =~ /\b(?:BUG|BUG_ON)\b/) {
+# avoid BUG() or BUG_ON() like mechanisms (exclude BUILD_BUG)
+		if ($line =~ /\b((?:[A-Z_]+_)?BUG(?:_ON(?:_[A-Z_]+)?))\s*\(/ &&
+		    $1 !~ /BUILD/) {
 			my $msg_type = \&WARN;
 			$msg_type = \&CHK if ($file);
 			&{$msg_type}("AVOID_BUG",

  reply	other threads:[~2016-10-05 17:01 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-04  4:00 BUG_ON() in workingset_node_shadows_dec() triggers Linus Torvalds
2016-10-04  4:07 ` Andrew Morton
2016-10-04  4:12   ` Linus Torvalds
2016-10-04  7:03     ` Raymond Jennings
2016-10-04 16:03       ` Linus Torvalds
2016-10-04  8:02 ` Greg KH
2016-10-04  9:32 ` Johannes Weiner
2016-10-05  1:21   ` Linus Torvalds
2016-10-05  9:25     ` Johannes Weiner
2016-10-05  9:31       ` Johannes Weiner
2016-10-05 10:40       ` Jan Kara
2016-10-05 16:10       ` Linus Torvalds
2016-10-05 17:00         ` Joe Perches [this message]
2016-10-05 17:07           ` [PATCH] checkpatch: extend BUG warning Linus Torvalds
2016-10-05  2:43 ` BUG_ON() in workingset_node_shadows_dec() triggers Paul Gortmaker
2016-10-05  3:29   ` Linus Torvalds
2016-10-05  5:44     ` Willy Tarreau
2016-10-05 15:52       ` Linus Torvalds
2016-10-05 19:06         ` Willy Tarreau
2016-10-05 19:18           ` Linus Torvalds
2016-10-05 21:09             ` Willy Tarreau
2016-10-05 21:14             ` Kees Cook
2016-10-05 21:46               ` Linus Torvalds
2016-10-05 22:17                 ` Kees Cook
2016-10-05 22:29                   ` Linus Torvalds
2016-10-06 22:07                     ` Kees Cook
2016-10-06 22:29                       ` Linus Torvalds
2016-10-06 23:05                         ` Kees Cook
2016-10-06 23:59                           ` Linus Torvalds
2016-10-07  5:48                             ` Willy Tarreau
2016-10-07 17:16                               ` Kees Cook
2016-10-07 17:21                                 ` Linus Torvalds
2016-10-07 17:33                                   ` Kees Cook
2016-10-07 18:26                                     ` Willy Tarreau
2016-10-06  1:59     ` Dave Chinner
2016-10-06  2:12       ` Linus Torvalds

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=1475686858.6105.7.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=davej@codemonkey.org.uk \
    --cc=david@fromorbit.com \
    --cc=hannes@cmpxchg.org \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=oleg@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=trapexit@spawn.link \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.