From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754102AbdDJRqM (ORCPT ); Mon, 10 Apr 2017 13:46:12 -0400 Received: from smtprelay0131.hostedemail.com ([216.40.44.131]:40391 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752347AbdDJRqI (ORCPT ); Mon, 10 Apr 2017 13:46:08 -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:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2197:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3653:3865:3866:3867:3868:3871:3874:5007:6261:9010:10004:10848:11658:11914:12043:12296:12555:12895:13069:13095:13181:13229:13311:13357:14181:14384:14394:14721:21080:21221:21433:30054:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: geese34_34035551dd829 X-Filterd-Recvd-Size: 2069 From: Joe Perches To: Andrew Morton , Andy Whitcroft Cc: Greg KH , Arthur Brainville , linux-kernel@vger.kernel.org Subject: [PATCH] checkpatch: Avoid suggesting struct definitions should be const Date: Mon, 10 Apr 2017 10:45:55 -0700 Message-Id: <0dce709150d712e66f1b90b03827634b53b28085.1491845946.git.joe@perches.com> X-Mailer: git-send-email 2.10.0.rc2.1.g053435c In-Reply-To: <20170409142812.3356-1-ybalrid@ybalrid.info> References: <20170409142812.3356-1-ybalrid@ybalrid.info> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Many structs are generally used const and there is a known list of these structs. struct definitions should not be generally be declared const. Add a test for the lack of an open brace immediately after the struct to avoid definitions. This avoids the false positive "struct foo should normally be const" message only when the open brace is on the same line as the definition. Signed-off-by: Joe Perches --- scripts/checkpatch.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 089c974aa3a5..3a1cb9d7474e 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6090,11 +6090,11 @@ sub process { } # check for various structs that are normally const (ops, kgdb, device_tree) +# and avoid what seem like struct definitions 'struct foo {' if ($line !~ /\bconst\b/ && - $line =~ /\bstruct\s+($const_structs)\b/) { + $line =~ /\bstruct\s+($const_structs)\b(?!\s*\{)/) { WARN("CONST_STRUCT", - "struct $1 should normally be const\n" . - $herecurr); + "struct $1 should normally be const\n" . $herecurr); } # use of NR_CPUS is usually wrong -- 2.10.0.rc2.1.g053435c