All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] checkpatch: suppress false long-line warining
@ 2017-12-05 16:34 Yury Norov
  0 siblings, 0 replies; only message in thread
From: Yury Norov @ 2017-12-05 16:34 UTC (permalink / raw)
  To: linux-kernel, Andy Whitcroft, Joe Perches; +Cc: Yury Norov

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 <ynorov@caviumnetworks.com>
CC: Joe Perches <joe@perches.com>
---
 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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-05 16:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-05 16:34 [PATCH v2] checkpatch: suppress false long-line warining Yury Norov

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.