All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] lib: remove leading spaces before tabs
@ 2021-06-08  7:14 Zhen Lei
  2021-06-08  8:44 ` Andy Shevchenko
  0 siblings, 1 reply; 14+ messages in thread
From: Zhen Lei @ 2021-06-08  7:14 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel; +Cc: Zhen Lei

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/'
2) Manually check and correct if necessary

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 lib/string.c               | 4 ++--
 lib/zlib_deflate/deflate.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/string.c b/lib/string.c
index 7548eb715ddb..b900c6c5efdf 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -982,7 +982,7 @@ void *memscan(void *addr, int c, size_t size)
 		p++;
 		size--;
 	}
-  	return (void *)p;
+	return (void *)p;
 }
 EXPORT_SYMBOL(memscan);
 #endif
@@ -1051,7 +1051,7 @@ void *memchr(const void *s, int c, size_t n)
 {
 	const unsigned char *p = s;
 	while (n-- != 0) {
-        	if ((unsigned char)c == *p++) {
+		if ((unsigned char)c == *p++) {
 			return (void *)(p - 1);
 		}
 	}
diff --git a/lib/zlib_deflate/deflate.c b/lib/zlib_deflate/deflate.c
index 8a878d0d892c..3fa66fc7fbd7 100644
--- a/lib/zlib_deflate/deflate.c
+++ b/lib/zlib_deflate/deflate.c
@@ -888,7 +888,7 @@ static block_state deflate_stored(
 	s->lookahead = 0;
 
 	/* Emit a stored block if pending_buf will be full: */
- 	max_start = s->block_start + max_block_size;
+	max_start = s->block_start + max_block_size;
         if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
 	    /* strstart == 0 is possible when wraparound on 16-bit machine */
 	    s->lookahead = (uInt)(s->strstart - max_start);
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-08  7:14 [PATCH 1/1] lib: remove leading spaces before tabs Zhen Lei
@ 2021-06-08  8:44 ` Andy Shevchenko
  2021-06-08  9:00   ` Leizhen (ThunderTown)
  0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2021-06-08  8:44 UTC (permalink / raw)
  To: Zhen Lei; +Cc: Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel

On Tue, Jun 8, 2021 at 10:14 AM Zhen Lei <thunder.leizhen@huawei.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/`.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-08  8:44 ` Andy Shevchenko
@ 2021-06-08  9:00   ` Leizhen (ThunderTown)
  2021-06-08 16:03     ` Joe Perches
  0 siblings, 1 reply; 14+ messages in thread
From: Leizhen (ThunderTown) @ 2021-06-08  9:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel



On 2021/6/8 16:44, Andy Shevchenko wrote:
> On Tue, Jun 8, 2021 at 10:14 AM Zhen Lei <thunder.leizhen@huawei.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.

> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-08  9:00   ` Leizhen (ThunderTown)
@ 2021-06-08 16:03     ` Joe Perches
  2021-06-09  5:15       ` Leizhen (ThunderTown)
  0 siblings, 1 reply; 14+ messages in thread
From: Joe Perches @ 2021-06-08 16:03 UTC (permalink / raw)
  To: Leizhen (ThunderTown), Andy Shevchenko
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel

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@huawei.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.

For instance:

$ git diff --stat lib
$ git ls-files lib/ | \
  xargs ./scripts/checkpatch.pl --types=SPACE_BEFORE_TAB --fix-inplace
<checkpatch output>
$ git diff --stat lib
 lib/atomic64_test.c             |   2 +-
 lib/bitmap.c                    |   4 +-
 lib/btree.c                     |   4 +-
 lib/decompress_bunzip2.c        |   6 +-
 lib/fonts/font_mini_4x6.c       | 512 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------
 lib/locking-selftest.c          |  12 ++--
 lib/lockref.c                   |   2 +-
 lib/lru_cache.c                 |   2 +-
 lib/math/rational-test.c        |   2 +-
 lib/nlattr.c                    |   4 +-
 lib/raid6/neon.c                |   2 +-
 lib/raid6/sse2.c                |  12 ++--
 lib/reed_solomon/reed_solomon.c |   4 +-
 lib/scatterlist.c               |   4 +-
 lib/string.c                    |   4 +-
 lib/test_firmware.c             |   2 +-
 lib/test_kmod.c                 |   2 +-
 lib/test_overflow.c             |   2 +-
 lib/textsearch.c                |   2 +-
 lib/ts_bm.c                     |   2 +-
 lib/zlib_deflate/deflate.c      |   2 +-
 21 files changed, 294 insertions(+), 294 deletions(-)



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-08 16:03     ` Joe Perches
@ 2021-06-09  5:15       ` Leizhen (ThunderTown)
  2021-06-09  5:52         ` Joe Perches
  2021-06-09  6:21         ` Leizhen (ThunderTown)
  0 siblings, 2 replies; 14+ messages in thread
From: Leizhen (ThunderTown) @ 2021-06-09  5:15 UTC (permalink / raw)
  To: Joe Perches, Andy Shevchenko
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel



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@huawei.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

Wow, It's so powerful. Thanks.

> <checkpatch output>
> $ git diff --stat lib
>  lib/atomic64_test.c             |   2 +-
>  lib/bitmap.c                    |   4 +-
>  lib/btree.c                     |   4 +-
>  lib/decompress_bunzip2.c        |   6 +-
>  lib/fonts/font_mini_4x6.c       | 512 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------

This file is horrible. It's hard not to correct it.

>  lib/locking-selftest.c          |  12 ++--
>  lib/lockref.c                   |   2 +-
>  lib/lru_cache.c                 |   2 +-
>  lib/math/rational-test.c        |   2 +-
>  lib/nlattr.c                    |   4 +-
>  lib/raid6/neon.c                |   2 +-
>  lib/raid6/sse2.c                |  12 ++--
>  lib/reed_solomon/reed_solomon.c |   4 +-
>  lib/scatterlist.c               |   4 +-
>  lib/string.c                    |   4 +-
>  lib/test_firmware.c             |   2 +-
>  lib/test_kmod.c                 |   2 +-
>  lib/test_overflow.c             |   2 +-
>  lib/textsearch.c                |   2 +-
>  lib/ts_bm.c                     |   2 +-
>  lib/zlib_deflate/deflate.c      |   2 +-
>  21 files changed, 294 insertions(+), 294 deletions(-)
> 
> 
> 
> .
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-09  5:15       ` Leizhen (ThunderTown)
@ 2021-06-09  5:52         ` Joe Perches
  2021-06-09  6:21         ` Leizhen (ThunderTown)
  1 sibling, 0 replies; 14+ messages in thread
From: Joe Perches @ 2021-06-09  5:52 UTC (permalink / raw)
  To: Leizhen (ThunderTown), Andy Shevchenko, Kenneth Albanowski
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel

On Wed, 2021-06-09 at 13:15 +0800, Leizhen (ThunderTown) wrote:
> On 2021/6/9 0:03, Joe Perches wrote:

> >  lib/fonts/font_mini_4x6.c       | 512 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------
> 
> This file is horrible. It's hard not to correct it.

Except for some trivial bits, I think it's brilliant.
A lot of handwork went into that thing.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-09  5:15       ` Leizhen (ThunderTown)
  2021-06-09  5:52         ` Joe Perches
@ 2021-06-09  6:21         ` Leizhen (ThunderTown)
  2021-06-09  6:35           ` Joe Perches
  2021-06-09 10:30           ` Andy Shevchenko
  1 sibling, 2 replies; 14+ messages in thread
From: Leizhen (ThunderTown) @ 2021-06-09  6:21 UTC (permalink / raw)
  To: Joe Perches, Andy Shevchenko
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel



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@huawei.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.

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/'

> 
> Wow, It's so powerful. Thanks.
> 
>>
>>
>>
>> .
>>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-09  6:21         ` Leizhen (ThunderTown)
@ 2021-06-09  6:35           ` Joe Perches
  2021-06-09 10:30           ` Andy Shevchenko
  1 sibling, 0 replies; 14+ messages in thread
From: Joe Perches @ 2021-06-09  6:35 UTC (permalink / raw)
  To: Leizhen (ThunderTown), Andy Shevchenko
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel

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@huawei.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



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-09  6:21         ` Leizhen (ThunderTown)
  2021-06-09  6:35           ` Joe Perches
@ 2021-06-09 10:30           ` Andy Shevchenko
  2021-06-09 13:31             ` Leizhen (ThunderTown)
  2021-06-09 21:44             ` Joe Perches
  1 sibling, 2 replies; 14+ messages in thread
From: Andy Shevchenko @ 2021-06-09 10:30 UTC (permalink / raw)
  To: Leizhen (ThunderTown)
  Cc: Joe Perches, Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel

On Wed, Jun 9, 2021 at 9:21 AM Leizhen (ThunderTown)
<thunder.leizhen@huawei.com> 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@huawei.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.

> >> 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.

If checkpath accepts infinite positional arguments, then proper way of
use (that's how I do with simple perl regexps) is to

scripts/checkpatch.pl --types=SPACE_BEFORE_TAB --fix-inplace -- $(git
ls-files lib/)

Seems like we have a shell lesson :-)

> 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/'


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-09 10:30           ` Andy Shevchenko
@ 2021-06-09 13:31             ` Leizhen (ThunderTown)
  2021-06-09 21:44             ` Joe Perches
  1 sibling, 0 replies; 14+ messages in thread
From: Leizhen (ThunderTown) @ 2021-06-09 13:31 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Joe Perches, Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton,
	linux-kernel



On 2021/6/9 18:30, Andy Shevchenko wrote:
> On Wed, Jun 9, 2021 at 9:21 AM Leizhen (ThunderTown)
> <thunder.leizhen@huawei.com> 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@huawei.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.
> 
>>>> 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.
> 
> If checkpath accepts infinite positional arguments, then proper way of
> use (that's how I do with simple perl regexps) is to
> 
> scripts/checkpatch.pl --types=SPACE_BEFORE_TAB --fix-inplace -- $(git
> ls-files lib/)

Nice. It's a little more concise.

> 
> Seems like we have a shell lesson :-)
> 
>> 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/'
> 
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-09 10:30           ` Andy Shevchenko
  2021-06-09 13:31             ` Leizhen (ThunderTown)
@ 2021-06-09 21:44             ` Joe Perches
  2021-06-10  9:10               ` Andy Shevchenko
  1 sibling, 1 reply; 14+ messages in thread
From: Joe Perches @ 2021-06-09 21:44 UTC (permalink / raw)
  To: Andy Shevchenko, Leizhen (ThunderTown)
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel

On Wed, 2021-06-09 at 13:30 +0300, Andy Shevchenko wrote:
> On Wed, Jun 9, 2021 at 9:21 AM Leizhen (ThunderTown)
> <thunder.leizhen@huawei.com> 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@huawei.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.
> 
> > > > 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.
> 
> If checkpath accepts infinite positional arguments, then proper way of
> use (that's how I do with simple perl regexps) is to
> 
> scripts/checkpatch.pl --types=SPACE_BEFORE_TAB --fix-inplace -- $(git ls-files lib/)

That won't always work:

$ git ls-files | xargs | wc -c
2716737

Nothing accepts infinite positional arguments.
You are always limited by the maximum length of a command line

$ getconf ARG_MAX
2097152

xargs has:

$ xargs --show-limits
Your environment variables take up 3517 bytes
POSIX upper limit on argument length (this system): 2091587
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2088070
Size of command buffer we are actually using: 131072
Maximum parallelism (--max-procs must be no greater): 2147483647

> Seems like we have a shell lesson :-)

Maybe so.

Using xargs allows use of -P to invoke parallelism.
Or you could just use gnu parallel instead of xargs.

Using './scripts/checkpatch.pl -- $(git ls-files <path>)' will only
allow a single process to be invoked for the files to be scanned.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-09 21:44             ` Joe Perches
@ 2021-06-10  9:10               ` Andy Shevchenko
  2021-06-10 12:05                 ` Joe Perches
  0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2021-06-10  9:10 UTC (permalink / raw)
  To: Joe Perches
  Cc: Leizhen (ThunderTown),
	Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel

On Wed, Jun 09, 2021 at 02:44:54PM -0700, Joe Perches wrote:
> On Wed, 2021-06-09 at 13:30 +0300, Andy Shevchenko wrote:
> > On Wed, Jun 9, 2021 at 9:21 AM Leizhen (ThunderTown)
> > <thunder.leizhen@huawei.com> 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@huawei.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.
> > 
> > > > > 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.
> > 
> > If checkpath accepts infinite positional arguments, then proper way of
> > use (that's how I do with simple perl regexps) is to
> > 
> > scripts/checkpatch.pl --types=SPACE_BEFORE_TAB --fix-inplace -- $(git ls-files lib/)
> 
> That won't always work:
> 
> $ git ls-files | xargs | wc -c
> 2716737
> 
> Nothing accepts infinite positional arguments.
> You are always limited by the maximum length of a command line
> 
> $ getconf ARG_MAX
> 2097152
> 
> xargs has:
> 
> $ xargs --show-limits
> Your environment variables take up 3517 bytes
> POSIX upper limit on argument length (this system): 2091587
> POSIX smallest allowable upper limit on argument length (all systems): 4096
> Maximum length of command we could actually use: 2088070
> Size of command buffer we are actually using: 131072
> Maximum parallelism (--max-procs must be no greater): 2147483647

If you care about parallelism, the checkpatch should be doing it itself.

Currently it's one perl interpreter with a single queue vs. zillions of perl
invocations (with all downsides of this). And I'm not sure which one is a
winning.

And yes, I'm aware of why xargs is ever exists (including handling of the
special file names).

> > Seems like we have a shell lesson :-)
> 
> Maybe so.
> 
> Using xargs allows use of -P to invoke parallelism.
> Or you could just use gnu parallel instead of xargs.
> 
> Using './scripts/checkpatch.pl -- $(git ls-files <path>)' will only
> allow a single process to be invoked for the files to be scanned.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-10  9:10               ` Andy Shevchenko
@ 2021-06-10 12:05                 ` Joe Perches
  2021-06-10 12:26                   ` Andy Shevchenko
  0 siblings, 1 reply; 14+ messages in thread
From: Joe Perches @ 2021-06-10 12:05 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Leizhen (ThunderTown),
	Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel

On Thu, 2021-06-10 at 12:10 +0300, Andy Shevchenko wrote:
> If you care about parallelism, the checkpatch should be doing it itself.

ridiculous argument.  g'night...




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/1] lib: remove leading spaces before tabs
  2021-06-10 12:05                 ` Joe Perches
@ 2021-06-10 12:26                   ` Andy Shevchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2021-06-10 12:26 UTC (permalink / raw)
  To: Joe Perches
  Cc: Leizhen (ThunderTown),
	Andy Shevchenko, Greg Kroah-Hartman, Andrew Morton, linux-kernel

On Thu, Jun 10, 2021 at 05:05:39AM -0700, Joe Perches wrote:
> On Thu, 2021-06-10 at 12:10 +0300, Andy Shevchenko wrote:
> > If you care about parallelism, the checkpatch should be doing it itself.
> 
> ridiculous argument.  g'night...

I don't think so. Not everyone runs checkpatch in parallel on 1000 core machine
with terabytes of RAM.

Good night!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-06-10 12:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08  7:14 [PATCH 1/1] lib: remove leading spaces before tabs Zhen Lei
2021-06-08  8:44 ` Andy Shevchenko
2021-06-08  9:00   ` Leizhen (ThunderTown)
2021-06-08 16:03     ` Joe Perches
2021-06-09  5:15       ` Leizhen (ThunderTown)
2021-06-09  5:52         ` Joe Perches
2021-06-09  6:21         ` Leizhen (ThunderTown)
2021-06-09  6:35           ` Joe Perches
2021-06-09 10:30           ` Andy Shevchenko
2021-06-09 13:31             ` Leizhen (ThunderTown)
2021-06-09 21:44             ` Joe Perches
2021-06-10  9:10               ` Andy Shevchenko
2021-06-10 12:05                 ` Joe Perches
2021-06-10 12:26                   ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.