public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Knut Omang <knut.omang@oracle.com>
To: Joe Perches <joe@perches.com>, linux-kernel@vger.kernel.org
Cc: Andy Whitcroft <apw@canonical.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dan Carpenter <error27@gmail.com>
Subject: Re: [PATCH v2 3/5] checkpatch: Improve --fix-inplace for TABSTOP
Date: Sat, 16 Dec 2017 16:55:56 +0100	[thread overview]
Message-ID: <1513439756.31439.5.camel@oracle.com> (raw)
In-Reply-To: <1513437230.4647.25.camel@perches.com>

On Sat, 2017-12-16 at 07:13 -0800, Joe Perches wrote:
> On Sat, 2017-12-16 at 15:42 +0100, Knut Omang wrote:
> > If the --fix-inplace option for TABSTOP encounters a sitation with several
> > spaces (but less than 8) at the end of an indentation, it will assume that there
> > are extra indentation and align back to the nearest tabstop instead of the next.
> > 
> > This might go undetected in a "full" checkpatch --fix-inplace run, as this
> > potential new error will be handled by SUSPECT_CODE_INDENT further down in the
> > script.  The code for TABSTOP have limited "knowledge" of the previous line.
> > Adding complexity when it is taken care of later anyway is maybe
> unnecessary/undesired.
> > As a simple heuristics just use a "natural" rounding algorithm and round
> > up for 4 spaces or more.
> > 
> > There's an example in line 108 in net/rds/ib_recv.c with indentation TAB + 7
> > spaces where the correct would have been an additional TAB.  With only TABSTOP
> > enabled, checkpatch will fix this to a single TAB, which is visually worse IMO.
> > 
> > Reported-by: Håkon Bugge <haakon.bugge@oracle.com>
> > Signed-off-by: Knut Omang <knut.omang@oracle.com>
> > Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>
> 
> Well written commit log description, thanks but
> I'm not sure that's actually better overall.
> 
> It's not possible to know if the appropriate thing
> to do is to add a tab or remove spaces.
> 
> This may get it wrong about as often as the current
> code gets it right.
> 
> Last I checked 6 months or so ago, there were ~8000
> TABSTOP warnings in the kernel tree.
> 
> Most of those still seem valid and moving additional
> places to the right is sometimes incorrect too.
> 
> It seems most common when there are 3 or 4 spaces
> used as indent level indentation instead of tabs.

I see your point here, definitely 
- more detailed statistics needed...

> Dunno.

Let me take this out of the set in the next version
as it is really a separate issue.

> Anyone else have an opinion?


Thanks,
Knut

>
> > ---
> >  scripts/checkpatch.pl | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 040aa79..febe010 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -2989,7 +2989,7 @@ sub process {
> >  				if (WARN("TABSTOP",
> >  					 "Statements should start on a tabstop\n" .
> $herecurr) &&
> >  				    $fix) {
> > -					$fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t"
> x ($indent/8)@e;
> > +					$fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t"
> x (($indent+4)/8)@e;
> >  				}
> >  			}
> >  		}

  reply	other threads:[~2017-12-16 15:56 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-16 14:42 [PATCH v2 0/5] Support for generalized use of make C={1,2} via a wrapper program Knut Omang
2017-12-16 14:42 ` [PATCH v2 1/5] runchecks: Generalize make C={1,2} to support multiple checkers Knut Omang
2017-12-16 14:42 ` [PATCH v2 2/5] Documentation: Add doc for runchecks, a checker runner Knut Omang
2017-12-16 15:08   ` Julia Lawall
2017-12-16 15:52     ` Knut Omang
2017-12-16 14:42 ` [PATCH v2 3/5] checkpatch: Improve --fix-inplace for TABSTOP Knut Omang
2017-12-16 15:13   ` Joe Perches
2017-12-16 15:55     ` Knut Omang [this message]
2017-12-16 14:42 ` [PATCH v2 4/5] rds: Add runchecks.cfg for net/rds Knut Omang
2017-12-16 17:45   ` Stephen Hemminger
2017-12-16 18:24     ` Joe Perches
2017-12-16 20:00       ` santosh.shilimkar
2017-12-17  2:02         ` Knut Omang
2017-12-18 19:28           ` Santosh Shilimkar
2017-12-17  1:57       ` Knut Omang
2017-12-17  1:46     ` Knut Omang
2017-12-16 14:42 ` [PATCH v2 5/5] RDMA/core: Add runchecks.cfg for drivers/infiniband/core Knut Omang
2017-12-18  8:02   ` Leon Romanovsky
2017-12-18 12:36     ` Knut Omang
2017-12-18 14:04       ` Leon Romanovsky
2017-12-18 15:23         ` Knut Omang
2017-12-18 19:03       ` Joe Perches
2017-12-18 19:18         ` Leon Romanovsky
2017-12-16 15:21 ` [PATCH v2 0/5] Support for generalized use of make C={1,2} via a wrapper program Joe Perches
2017-12-16 16:27   ` Knut Omang
2017-12-16 17:00     ` Joe Perches
2017-12-16 17:11       ` Knut Omang
2017-12-16 17:47 ` Stephen Hemminger
2017-12-16 18:02   ` Joe Perches
2017-12-17  2:14   ` Knut Omang
2017-12-18  5:00     ` Jason Gunthorpe
2017-12-18  6:00       ` Joe Perches
2017-12-18 13:05         ` Knut Omang
2017-12-18 15:30           ` Joe Perches
2017-12-18 16:41             ` Knut Omang
2017-12-18 17:49           ` Jason Gunthorpe
2017-12-18 17:46         ` Jason Gunthorpe
2017-12-18 17:53           ` Joe Perches
2017-12-18 17:56           ` Bart Van Assche
2017-12-18 18:39             ` Knut Omang
2017-12-18 19:24               ` Leon Romanovsky
2017-12-18 13:41       ` Knut Omang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1513439756.31439.5.camel@oracle.com \
    --to=knut.omang@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=error27@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox