lib: remove leading spaces before tabs
Subsystems (2)
PATCH 1/1 lib: remove leading spaces before tabs
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
--- lib/string.c | 4 ++-- lib/zlib_deflate/deflate.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/string.c +2 -2
@@ -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 ); } }
lib/zlib_deflate/deflate.c +1 -1
@@ -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);
Signature · 1 line
2.25.1
Quoted 4 lines · 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/'
Hint for the future, try to use what Git provides, for example git ls-files -- lib/.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · 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/'Hint for the future, try to use what Git provides, for example
git ls-files -- lib/.
Okay, thanks. I learned a new trick.
Quoted 1 line
Quoted 11 lines · Leizhen (ThunderTown)
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Zhen Lei
1) Run the following command to find and remove the leading spaces before tabs:
findlib/-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(-)
Quoted 11 lines · Joe Perches
Quoted 10 lines · Leizhen (ThunderTown)
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Zhen Lei
1) Run the following command to find and remove the leading spaces before tabs:
findlib/-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/.
Quoted 8 lines
Quoted 1 line
Okay, thanks. I learned a new trick.
Perhaps another 'trick'.
checkpatch has
SPACE_BEFORE_TABwhich 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 indrivers/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.
Quoted 6 lines
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.
Quoted 7 lines
<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.
Quoted 22 lines
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(-).
Quoted 5 lines · Leizhen (ThunderTown)
Quoted 1 line · Joe Perches
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.
Quoted 23 lines · Leizhen (ThunderTown)
Quoted 11 lines · Joe Perches
Quoted 10 lines · Leizhen (ThunderTown)
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Zhen Lei
1) Run the following command to find and remove the leading spaces before tabs:
findlib/-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/.Quoted 8 lines
Quoted 1 line
Okay, thanks. I learned a new trick.
Perhaps another 'trick'.
checkpatch has
SPACE_BEFORE_TABwhich 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 indrivers/staging/paths.
Quoted 11 lines
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.
Quoted 6 lines
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/'
Quoted 8 lines
Wow, It's so powerful. Thanks.
Quoted 5 lines
.
Quoted 28 lines · Leizhen (ThunderTown)
Quoted 27 lines · Leizhen (ThunderTown)
Quoted 11 lines · Joe Perches
Quoted 10 lines · Leizhen (ThunderTown)
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Zhen Lei
1) Run the following command to find and remove the leading spaces before tabs:
findlib/-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/.Quoted 8 lines
Quoted 1 line
Okay, thanks. I learned a new trick.
Perhaps another 'trick'.
checkpatch has
SPACE_BEFORE_TABwhich 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 indrivers/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.
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
For instance:
$ git diff --stat lib $ git ls-files lib/ | \ xargs ./scripts/checkpatch.pl --types=SPACE_BEFORE_TAB --fix-inplaceI just tried it. It's too slow.
Slow is relative. checkpatch always does all its tests and then only reports on the selected ones.
Quoted 3 lines
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
Quoted 15 lines · Leizhen (ThunderTown)
Quoted 13 lines · Leizhen (ThunderTown)
Quoted 12 lines · Joe Perches
Quoted 11 lines · Leizhen (ThunderTown)
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · 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/'Hint for the future, try to use what Git provides, for example
git ls-files -- lib/.Okay, thanks. I learned a new trick.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
For instance:
$ git diff --stat lib $ git ls-files lib/ | \ xargs ./scripts/checkpatch.pl --types=SPACE_BEFORE_TAB --fix-inplaceI 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 :-)
Quoted 3 lines
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/'
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 23 lines · Andy Shevchenko
Quoted 21 lines · Leizhen (ThunderTown)
Quoted 19 lines · Leizhen (ThunderTown)
Quoted 18 lines · Joe Perches
Quoted 11 lines · Leizhen (ThunderTown)
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · 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/'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
Quoted 7 lines
Quoted 1 line
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-fileslib/)
Nice. It's a little more concise.
Quoted 8 lines
Seems like we have a shell lesson :-)
Quoted 3 lines
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/'
Quoted 23 lines · Andy Shevchenko
Quoted 21 lines · Leizhen (ThunderTown)
Quoted 19 lines · Leizhen (ThunderTown)
Quoted 18 lines · Joe Perches
Quoted 11 lines · Leizhen (ThunderTown)
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Zhen Lei
1) Run the following command to find and remove the leading spaces before tabs:
findlib/-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
Quoted 6 lines
Quoted 1 line
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-fileslib/)
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
Quoted 1 line
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.
Quoted 44 lines · Joe Perches
Quoted 23 lines · Andy Shevchenko
Quoted 21 lines · Leizhen (ThunderTown)
Quoted 19 lines · Leizhen (ThunderTown)
Quoted 18 lines · Joe Perches
Quoted 11 lines · Leizhen (ThunderTown)
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Zhen Lei
1) Run the following command to find and remove the leading spaces before tabs:
findlib/-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-inplaceQuoted 6 lines
Quoted 1 line
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-fileslib/)That won't always work:
$ git ls-files | xargs | wc -c 2716737Nothing accepts infinite positional arguments.
You are always limited by the maximum length of a command line$ getconf ARG_MAX 2097152xargs has:
Quoted 7 lines
$ 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).
Quoted 9 lines
Quoted 1 line
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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 1 line · Andy Shevchenko
If you care about parallelism, the checkpatch should be doing it itself.
ridiculous argument. g'night...
Quoted 4 lines · Joe Perches
Quoted 1 line · Andy Shevchenko
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!
Signature · 2 lines
With Best Regards, Andy Shevchenko