From patchwork Thu May 21 01:02:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 474707 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8763E1402A1 for ; Thu, 21 May 2015 11:02:13 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753783AbbEUBCM (ORCPT ); Wed, 20 May 2015 21:02:12 -0400 Received: from smtprelay0049.hostedemail.com ([216.40.44.49]:52570 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752819AbbEUBCL (ORCPT ); Wed, 20 May 2015 21:02:11 -0400 Received: from filter.hostedemail.com (unknown [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 1B531C1F72; Thu, 21 May 2015 01:02:10 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2, 0, 0, , d41d8cd98f00b204, joe@perches.com, :::::::::::::::::::::, RULES_HIT:41:355:379:541:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1500:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3872:3874:4321:4823:5007:6120:6261:7875:8957:10004:10400:10848:10967:11232:11658:11914:12043:12296:12517:12519:12555:12663:12740:13019:13149:13230:13255: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: nail97_129d615086047 X-Filterd-Recvd-Size: 3546 Received: from joe-X200MA.home (pool-173-51-221-2.lsanca.fios.verizon.net [173.51.221.2]) (Authenticated sender: joe@perches.com) by omf01.hostedemail.com (Postfix) with ESMTPA; Thu, 21 May 2015 01:02:07 +0000 (UTC) Message-ID: <1432170126.20840.22.camel@perches.com> Subject: [RFC PATCH] checkpatch: check for 2 or more spaces around assignment of a declaration From: Joe Perches To: Jean Delvare , Andrew Morton Cc: Sudip Mukherjee , Wolfram Sang , Tim Waugh , Willy Tarreau , Greg Kroah-Hartman , Alan Cox , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devel@driverdev.osuosl.org Date: Wed, 20 May 2015 18:02:06 -0700 In-Reply-To: <20150520195918.1c150979@endymion.delvare> References: <1432135622-8288-1-git-send-email-sudipm.mukherjee@gmail.com> <1432135622-8288-5-git-send-email-sudipm.mukherjee@gmail.com> <20150520154907.GB2001@katana> <20150520171452.GA9069@sudip-PC> <20150520195918.1c150979@endymion.delvare> X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org On Wed, 2015-05-20 at 19:59 +0200, Jean Delvare wrote: > On Wed, 20 May 2015 22:44:52 +0530, Sudip Mukherjee wrote: > > On Wed, May 20, 2015 at 05:49:07PM +0200, Wolfram Sang wrote: > > > On Wed, May 20, 2015 at 08:57:00PM +0530, Sudip Mukherjee wrote: > > > > static struct parport_driver i2c_parport_driver = { > > > > - .name = "i2c-parport", > > > > - .attach = i2c_parport_attach, > > > > - .detach = i2c_parport_detach, > > > > + .name = "i2c-parport", > > > > + .match_port = i2c_parport_attach, > > > > + .detach = i2c_parport_detach, > > > > + .devmodel = true, > > > > > > Minor nit: I prefer to not use tabs but a single space after the struct > > > member names. Less hazzle in the future and still readable IMO. > > > > It was having space originally. I changed that into tab as it was > > looking good with them as aligned. > > As the driver maintainer, I am fine with both unaligned or tab-aligned. > Space-aligned as I did originally was not a good idea, I admit. Perhaps space aligned declarations should have some checkpatch --strict warning for 2 or more spaces around any assignment of the declaration. int a = 1; // 2+ spaces before = int b = 2; // 2+ spaces after = int c = 3; // uses tabs around =, no warning int d = 4; // uses 2 tabs before =, no warning Something like: --- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 89b1df4..8f9d26f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3902,6 +3902,13 @@ sub process { "multiple assignments should be avoided\n" . $herecurr); } +# check for space aligned declarations + if ($line =~ /^.\s*(?:$Declare|$DeclareMisordered)\s*$Ident {2,}=\s*(?:$Lval|$Constant|$String)/ || + $line =~ /^.\s*(?:$Declare|$DeclareMisordered)\s*$Ident\s*= {2,}(?:$Lval|$Constant|$String)/) { + CHK("SPACING", + "Avoid multiple space assigments - prefer a single space or tabs\n" . $herecurr); + } + ## # check for multiple declarations, allowing for a function declaration ## # continuation. ## if ($line =~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Ident.*/ &&