Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751632AbbEJQwJ (ORCPT ); Sun, 10 May 2015 12:52:09 -0400 Received: from smtprelay0236.hostedemail.com ([216.40.44.236]:52868 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751431AbbEJQwH (ORCPT ); Sun, 10 May 2015 12:52:07 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:599:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3165:3355:3622:3653:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:4605:5007:6120:6261:7875:7901:7903:8957:9390:10004:10400:10848:11232:11658:11914:12043:12438:12517:12519:12740:13095:13161:13229:14093:14097: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: blade07_69a286a5f221c X-Filterd-Recvd-Size: 3425 Message-ID: <1431276724.29257.20.camel@perches.com> Subject: Re: [PATCH RFC V2] checkpatch: flag split arithmetic operations with CHECK From: Joe Perches To: Nicholas Mc Guire Cc: Andy Whitcroft , linux-kernel@vger.kernel.org Date: Sun, 10 May 2015 09:52:04 -0700 In-Reply-To: <1431257186-18013-1-git-send-email-hofrat@osadl.org> References: <1431257186-18013-1-git-send-email-hofrat@osadl.org> 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: 2775 Lines: 75 On Sun, 2015-05-10 at 13:26 +0200, Nicholas Mc Guire wrote: > Simple arithmetic operations should be on one line, if they can be fit, > rather than splitting at the operator. As this is not in the CodingStyle it > is limited to --strict use of checkpatch.pl and emits a CHECK only. The "if they can fit" is an important consideration not addressed by this patch. > This extension should flag such lines as CHECK only, as this is not > mandated by the CodingStyle and in some cases they seem justified > (e.g. kernel/sched/fair.c:760 and a few other examples in that file) > TODO: Move to "# Check operator spacing" section as Joe Perches > requested - simply got completely lost in that section... > Also not clear if it really is the right place to put it - > spacing issues and split operators are two quite different > problems. > Question: There are many (518) "lines over 80 char" warnings but that > seems to be accepted in checkpatch.pl - should those be > wrapped ? perl is not c Regexs are often quite long so I think trying to do 80 column wrapping is something that would make checkpatch even less readable. > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -2577,6 +2577,58 @@ sub process { > "Logical continuations should be on the previous line\n" . $hereprev); > } > > +# check for + or - at the end of a line but ignore --/++ > + if (!($rawline =~ /^\+.*(\+\+|--).*$/) && > + $rawline =~ /^\+.*(\+|-)$/) { > + my $opline = $line; $opline =~ s/^./ /; > + my ($curr_values, $types) = annotate_values($opline . "\n", $prev_values); > + # its type and the end 'B' -> binary * -> fuss > + if($types =~ m/^.*B$/) { > + CHK("ARITHMETIC_CONTINUATIONS", > + "Arithmetic expressions should be on one line\n" . $hereprev); This message is unclear. Arithmetic should not be on one line as that conflicts with line length limits. This test is similar to the logical operator continuation test at line 2574. Maybe the message would be clearer with "Arithmetic operator should be on the previous line\n" But more globally, maybe this style and message should be used for many different operators: o multiplicative (*, /, %) o additive (+, -) o bitwise shift (<<, >>) o relational (<, >, <=, >=) o equality (==, !=) o bitwise (&, ^, |) o logical (&&, ||) o assignment (=, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=) That's a rather bigger change though and would be better done with more discussion first. -- 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/