* [PATCH] checkpatch: include text files in SPACE_BEFORE_TAB test
@ 2014-12-06 5:45 Frank Rowand
2014-12-08 10:41 ` Andy Whitcroft
0 siblings, 1 reply; 2+ messages in thread
From: Frank Rowand @ 2014-12-06 5:45 UTC (permalink / raw)
To: Andy Whitcroft, Joe Perches, Linux Kernel list, frowand.list
From: Frank Rowand <frank.rowand@sonymobile.com>
git-am whined about a patch that I submitted for the Documentation
subtree, (https://lkml.org/lkml/2014/11/24/636) but checkpatch does
not. Make checkpatch just as whiney.
This patch moves the SPACE_BEFORE_TAB test before the check that
excludes text files and also before the test that excludes
assembly files. It seems to me that both CODE_INDENT and
SPACE_BEFORE_TAB are valid tests for assembly files, but I
added an if around the moved CODE_INDENT test to include only
source files, not including assembly files. Thus this patch
does not change which files are subject to CODE_INDENT.
The CODE_INDENT test is moved along with the SPACE_BEFORE_TAB
test because the c76f4cb3d25e commit log says:
This SPACE_BEFORE_TAB test is done after CODE_INDENT.
If there are spaces used at the beginning of a line that should be
converted to tabs, please make sure that the CODE_INDENT test and
conversion is done before this SPACE_BEFORE_TAB test and conversion.
Signed-off-by: Frank Rowand <frank.rowand@sonymobile.com>
---
Andy, Joe,
Assembly files are still excluded from the CODE_INDENT test -- do you
want to make another change to include them?
---
scripts/checkpatch.pl | 56 ++++++++++++++++++++++++++------------------------
1 file changed, 30 insertions(+), 26 deletions(-)
Index: b/scripts/checkpatch.pl
===================================================================
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2389,6 +2389,36 @@ sub process {
}
}
+# at the beginning of a line any tabs must come first and anything
+# more than 8 must use tabs.
+# do CODE_INDENT test before SPACE_BEFORE_TAB test (c76f4cb3d25e)
+ if ($realfile =~ /\.(h|c|pl|dtsi|dts)$/) {
+ if ($rawline =~ /^\+\s* \t\s*\S/ ||
+ $rawline =~ /^\+\s* \s*/) {
+ my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+ $rpt_cleaners = 1;
+ if (ERROR("CODE_INDENT",
+ "code indent should use tabs where possible\n" . $herevet) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e;
+ }
+ }
+ }
+
+# check for space before tabs.
+ if ($rawline =~ /^\+/ && $rawline =~ / \t/) {
+ my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+ if (WARN("SPACE_BEFORE_TAB",
+ "please, no space before tabs\n" . $herevet) &&
+ $fix) {
+ while ($fixed[$fixlinenr] =~
+ s/(^\+.*) {8,8}\t/$1\t\t/) {}
+ while ($fixed[$fixlinenr] =~
+ s/(^\+.*) +\t/$1\t/) {}
+ }
+ }
+
+
# check we are in a valid source file if not then ignore this hunk
next if ($realfile !~ /\.(h|c|s|S|pl|sh|dtsi|dts)$/);
@@ -2453,32 +2483,6 @@ sub process {
# check we are in a valid source file C or perl if not then ignore this hunk
next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
-# at the beginning of a line any tabs must come first and anything
-# more than 8 must use tabs.
- if ($rawline =~ /^\+\s* \t\s*\S/ ||
- $rawline =~ /^\+\s* \s*/) {
- my $herevet = "$here\n" . cat_vet($rawline) . "\n";
- $rpt_cleaners = 1;
- if (ERROR("CODE_INDENT",
- "code indent should use tabs where possible\n" . $herevet) &&
- $fix) {
- $fixed[$fixlinenr] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e;
- }
- }
-
-# check for space before tabs.
- if ($rawline =~ /^\+/ && $rawline =~ / \t/) {
- my $herevet = "$here\n" . cat_vet($rawline) . "\n";
- if (WARN("SPACE_BEFORE_TAB",
- "please, no space before tabs\n" . $herevet) &&
- $fix) {
- while ($fixed[$fixlinenr] =~
- s/(^\+.*) {8,8}\t/$1\t\t/) {}
- while ($fixed[$fixlinenr] =~
- s/(^\+.*) +\t/$1\t/) {}
- }
- }
-
# check for && or || at the start of a line
if ($rawline =~ /^\+\s*(&&|\|\|)/) {
CHK("LOGICAL_CONTINUATIONS",
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] checkpatch: include text files in SPACE_BEFORE_TAB test
2014-12-06 5:45 [PATCH] checkpatch: include text files in SPACE_BEFORE_TAB test Frank Rowand
@ 2014-12-08 10:41 ` Andy Whitcroft
0 siblings, 0 replies; 2+ messages in thread
From: Andy Whitcroft @ 2014-12-08 10:41 UTC (permalink / raw)
To: Frank Rowand; +Cc: Joe Perches, Linux Kernel list
On Fri, Dec 05, 2014 at 09:45:37PM -0800, Frank Rowand wrote:
> From: Frank Rowand <frank.rowand@sonymobile.com>
>
> git-am whined about a patch that I submitted for the Documentation
> subtree, (https://lkml.org/lkml/2014/11/24/636) but checkpatch does
> not. Make checkpatch just as whiney.
>
> This patch moves the SPACE_BEFORE_TAB test before the check that
> excludes text files and also before the test that excludes
> assembly files. It seems to me that both CODE_INDENT and
> SPACE_BEFORE_TAB are valid tests for assembly files, but I
> added an if around the moved CODE_INDENT test to include only
> source files, not including assembly files. Thus this patch
> does not change which files are subject to CODE_INDENT.
>
> The CODE_INDENT test is moved along with the SPACE_BEFORE_TAB
> test because the c76f4cb3d25e commit log says:
>
> This SPACE_BEFORE_TAB test is done after CODE_INDENT.
>
> If there are spaces used at the beginning of a line that should be
> converted to tabs, please make sure that the CODE_INDENT test and
> conversion is done before this SPACE_BEFORE_TAB test and conversion.
>
> Signed-off-by: Frank Rowand <frank.rowand@sonymobile.com>
> ---
>
>
> Andy, Joe,
>
> Assembly files are still excluded from the CODE_INDENT test -- do you
> want to make another change to include them?
The format of assembly files is rather variable. Tabs are not used in the
same way as in the rest of the kernel. It is not clear you can guarentee
that the rules are appropriate there. They are also vary rarely edited
in the greater scheme of things.
-apw
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-08 10:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-06 5:45 [PATCH] checkpatch: include text files in SPACE_BEFORE_TAB test Frank Rowand
2014-12-08 10:41 ` Andy Whitcroft
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox