From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Message-ID: <1475686858.6105.7.camel@perches.com> Subject: [PATCH] checkpatch: extend BUG warning From: Joe Perches To: Linus Torvalds , Johannes Weiner , Andy Whitcroft Cc: Andrew Morton , Antonio SJ Musumeci , Miklos Szeredi , Dave Jones , Oleg Nesterov , Dave Chinner , Michal Hocko , Jan Kara , Linux Kernel Mailing List , stable Date: Wed, 05 Oct 2016 10:00:58 -0700 In-Reply-To: References: <20161004093216.GA21170@cmpxchg.org> <20161005092534.GA20174@cmpxchg.org> Content-Type: text/plain; charset="ISO-8859-1" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: 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 Signed-off-by: Joe Perches --- �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",