2017-12-05 16:34:43

by Yury Norov

[permalink] [raw]
Subject: [PATCH v2] checkpatch: suppress false long-line warining

For DOS-formatted patches, extra ^M symbol at the end of line
increases overall line length by 1.

It triggers unneeded warning if line is exactly 80 chars length.
This patch fixes it.

Discovered in discussion to this patch:
https://lkml.org/lkml/2017/11/25/24

v2: simplify as suggested by Joe Perches.

Signed-off-by: Yury Norov <[email protected]>
CC: Joe Perches <[email protected]>
---
scripts/checkpatch.pl | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 040aa79e1d9d..e7b941b8e6d7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2732,6 +2732,13 @@ sub process {

#trailing whitespace
if ($line =~ /^\+.*\015/) {
+ # If DOS line detected, additional ^M symbol at the end
+ # of line increases line length, so remove that ^M and
+ # decrease $length to avoid false positives when
+ # checking length of the line.
+ $line =~ s/[\s\015]+$//;
+ $length--;
+
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
if (ERROR("DOS_LINE_ENDINGS",
"DOS line endings\n" . $herevet) &&
--
2.11.0