From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754004AbcJERBE (ORCPT ); Wed, 5 Oct 2016 13:01:04 -0400 Received: from smtprelay0241.hostedemail.com ([216.40.44.241]:46750 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752346AbcJERBD (ORCPT ); Wed, 5 Oct 2016 13:01:03 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::,RULES_HIT:41:355:379:541:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2197:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3653:3865:3868:3874:4250:4321:5007:6119:8784:10004:10400:10848:11026:11473:11658:11783:11914:12043:12438:12555:13069:13311:13357:13439:13894:14181:14394:14659:14721:21080:21221:30054:30060:30090,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:5,LUA_SUMMARY:none X-HE-Tag: tree85_7d08b9ffb7635 X-Filterd-Recvd-Size: 3228 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" X-Mailer: Evolution 3.22.0-2ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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", 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",