Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932569AbbERQXD (ORCPT ); Mon, 18 May 2015 12:23:03 -0400 Received: from smtprelay0162.hostedemail.com ([216.40.44.162]:40075 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932538AbbERQWp (ORCPT ); Mon, 18 May 2015 12:22:45 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:599:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2553:2559:2562:2691:2828:2892:3138:3139:3140:3141:3142:3354:3622:3653:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:4362:4385:4470:5007:6261:6691:7875:7903:8957:9040:10004:10400:10848:11232:11658:11914:12043:12296:12517:12519:12663:12740:13069:13255:13311:13357:21080,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 X-HE-Tag: rate49_17cf7656a172c X-Filterd-Recvd-Size: 2825 Message-ID: <1431966162.2870.22.camel@perches.com> Subject: Re: [PATCH] checkpatch: types found in one source file do not affect processing of others From: Joe Perches To: Alex Dowad Cc: Andy Whitcroft , open list Date: Mon, 18 May 2015 09:22:42 -0700 In-Reply-To: <1431956009-16076-1-git-send-email-alexinbeijing@gmail.com> References: <1431956009-16076-1-git-send-email-alexinbeijing@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2151 Lines: 57 On Mon, 2015-05-18 at 15:33 +0200, Alex Dowad wrote: > checkpatch uses various cues in its input files to discover the names of > user-defined types. It then uses that information when processing expressions, > to discover more style issues. > > Unfortunately, in rare cases, this means that checkpatch may give different > results if you run it on several files at the same time, or one by one! The > reason is that it may identify a type (or something that looks like a type) > in one file, and then carry this information over when processing a different > file. True, thanks. I found the same thing, but hadn't gotten 'round to submitting a patch for it. > keep user-defined types in a separate array from built-in ones, > and reset the array of user-defined types at the beginning of each new > source file. [] > I am not a Perl programmer -- please let me know if there is a better way to > accomplish what I am trying to do here. I think nearly no-one _wants_ to be a perl monk. (Except maybe for the free beer) > @@ -511,7 +515,7 @@ $misspellings = join("|", sort keys %spelling_fix) if keys %spelling_fix; > > sub build_types { > my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; > - my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; > + my $all = "(?x: \n" . join("|\n ", @allTypeList) . "\n)"; > my $Misordered = "(?x: \n" . join("|\n ", @typeListMisordered) . "\n)"; > my $allWithAttr = "(?x: \n" . join("|\n ", @typeListWithAttr) . "\n)"; > $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; > @@ -745,6 +749,7 @@ for my $filename (@ARGV) { > @fixed = (); > @fixed_inserted = (); > @fixed_deleted = (); > + @allTypeList = (@typeList); > $fixlinenr = -1; > } I think a proper solution requires a bit more than this. I believe both @modifierList and @typeList need to be reset before each new file is processed. I'll play with it. Thanks Alex. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/