lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f86508661238686a4998c7d9fae3a6c1ddd07ee5.camel@perches.com>
Date:   Tue, 08 Jun 2021 23:35:28 -0700
From:   Joe Perches <joe@...ches.com>
To:     "Leizhen (ThunderTown)" <thunder.leizhen@...wei.com>,
        Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     Andy Shevchenko <andy@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] lib: remove leading spaces before tabs

On Wed, 2021-06-09 at 14:21 +0800, Leizhen (ThunderTown) wrote:
> On 2021/6/9 13:15, Leizhen (ThunderTown) wrote:
> > On 2021/6/9 0:03, Joe Perches wrote:
> > > On Tue, 2021-06-08 at 17:00 +0800, Leizhen (ThunderTown) wrote:
> > > > On 2021/6/8 16:44, Andy Shevchenko wrote:
> > > > > On Tue, Jun 8, 2021 at 10:14 AM Zhen Lei <thunder.leizhen@...wei.com> wrote:
> > > > > > 
> > > > > > 1) Run the following command to find and remove the leading spaces before
> > > > > >    tabs:
> > > > > >    find lib/ -type f | xargs sed -r -i 's/^[ ]+\t/\t/'
> > > > > 
> > > > > Hint for the future, try to use what Git provides, for example `git
> > > > > ls-files -- lib/`.
> > > > 
> > > > Okay, thanks. I learned a new trick.
> > > 
> > > Perhaps another 'trick'.
> > > 
> > > checkpatch has SPACE_BEFORE_TAB which does this for any spaces before
> > > a tab, not just at the start of lines.  But as you've no doubt seen,
> > > many maintainers do not care for this sort of whitespace only change
> > > so it's best to do this sparingly or only in drivers/staging/ paths.
> > 
> > I've always thought of kernel, mm, and lib as the core modules of Linux,
> > and they serve as showcases for successors. I'm not interested in making
> > coding style improvements unless it's a work-related driver that I
> > usually read.
> > 
> > > 
> > > For instance:
> > > 
> > > $ git diff --stat lib
> > > $ git ls-files lib/ | \
> > >   xargs ./scripts/checkpatch.pl --types=SPACE_BEFORE_TAB --fix-inplace
> 
> I just tried it. It's too slow.

Slow is relative.  checkpatch always does all its tests and then
only reports on the selected ones.

> The command I used earlier, removing the line start match "^", can also do that.
> 
> git ls-files lib/ | xargs sed -r -i 's/[ ]+\t/\t/'

Not quite.  

Equivalent perl code to checkpatch would be:

	while ($_) =~ s/(^.*) {8,8}\t/$1\t\t/) {}
	while ($_) =~ s/(^.*) +\t/$1\t/) {}

This would convert all 8 count of spaces before a tab to tab and then
remove any other spaces before tabs regardless of location in the line
and not just at the beginning of a line.

cheers, Joe


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ