From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751192AbdK1FE3 (ORCPT ); Tue, 28 Nov 2017 00:04:29 -0500 Received: from smtprelay0063.hostedemail.com ([216.40.44.63]:34831 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750933AbdK1FE2 (ORCPT ); Tue, 28 Nov 2017 00:04:28 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 30,2,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:334:355:368:369:379:541:599:800:960:967:968:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1381:1437:1515:1516:1518:1534:1543:1593:1594:1711:1730:1747:1777:1792:2197:2199:2393:2525:2553:2560:2563:2682:2685:2828:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3354:3622:3653:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:5007:7875:7903:8531:9025:10004:10400:10848:11026:11232:11473:11658:11914:12043:12049:12296:12740:12760:12895:13146:13230:13439:14181:14659:14721:21080:21221:21451:21505:21627:30054:30070:30089:30090: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: rat73_43eb0a9a35151 X-Filterd-Recvd-Size: 3917 Message-ID: <1511845464.32426.94.camel@perches.com> Subject: Re: [PATCH] checkpatch: suppress false long-line warining From: Joe Perches To: Yury Norov , Andy Whitcroft , linux-kernel@vger.kernel.org Date: Mon, 27 Nov 2017 21:04:24 -0800 In-Reply-To: <20171128023938.19872-1-ynorov@caviumnetworks.com> References: <20171128023938.19872-1-ynorov@caviumnetworks.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 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 On Tue, 2017-11-28 at 05:39 +0300, Yury Norov wrote: > For DOS-formatted patches, extra ^M symbol at the end of line > increases overall line length by 1. > > It triggers unneeded warning if line is exactly 80 chars length. > This patch fixes it. It's may be simpler to just remove the \015 from the input line > Discovered in discussion to this patch: > https://lkml.org/lkml/2017/11/25/24 > > Signed-off-by: Yury Norov > --- > scripts/checkpatch.pl | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -59,6 +59,7 @@ my $conststructsfile = "$D/const_structs.checkpatch"; > my $typedefsfile = ""; > my $color = "auto"; > my $allow_c99_comments = 1; > +my $is_dos_line; > > sub help { > my ($exitcode) = @_; > @@ -2731,7 +2732,9 @@ sub process { > next if (!$hunk_line || $line =~ /^-/); > > #trailing whitespace > + $is_dos_line = 0; > if ($line =~ /^\+.*\015$/) { Maybe: $line =~ /\015$//; $length--; and nothing else > + $is_dos_line = 1 if (!$fix_inplace); > my $herevet = "$here\n" . cat_vet($rawline) . "\n"; > if (ERROR("DOS_LINE_ENDINGS", > "DOS line endings\n" . $herevet) && > @@ -2884,7 +2887,12 @@ sub process { > # if LONG_LINE is ignored, the other 2 types are also ignored > # > > - if ($line =~ /^\+/ && $length > $max_line_length) { > + # If DOS line detected, additional ^M symbol at the end of > + # line increases line length, so increase max_line_length > + # accordingly. > + my $__max_line_length = $max_line_length + $is_dos_line; > + > + if ($line =~ /^\+/ && $length > $__max_line_length) { > my $msg_type = "LONG_LINE"; > > # Check the allowed long line types first > @@ -2892,7 +2900,7 @@ sub process { > # logging functions that end in a string that starts > # before $max_line_length > if ($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(?:KERN_\S+\s*|[^"]*))?($String\s*(?:|,|\)\s*;)\s*)$/ && > - length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) { > + length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $__max_line_length) { > $msg_type = ""; > > # lines with only strings (w/ possible termination) > @@ -2910,12 +2918,12 @@ sub process { > > # a comment starts before $max_line_length > } elsif ($line =~ /($;[\s$;]*)$/ && > - length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) { > + length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $__max_line_length) { > $msg_type = "LONG_LINE_COMMENT" > > # a quoted string starts before $max_line_length > } elsif ($sline =~ /\s*($String(?:\s*(?:\\|,\s*|\)\s*;\s*))?)$/ && > - length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) { > + length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $__max_line_length) { > $msg_type = "LONG_LINE_STRING" > } >