[ovs-dev] [PATCH v1] checkpatch: Correct line count in error messages

Mike Pattrick mkp at redhat.com
Wed Nov 17 19:33:20 UTC 2021

As part of some previous checkpatch work, we discovered that checkpatch
isn't always reporting correct line numbers. As it turns out, Python's
splitlines function considers several characters to be new lines which
common text editors do not typically consider to be new lines. For
example, form feed characters, which this code base uses to cluster

To retain a very similar functionality to what exists now, we will
split on "\r?\n" and strip off the other characters that previously
splitlines was splitting on.

Signed-off-by: Mike Pattrick <mkp at redhat.com>
 utilities/checkpatch.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index bf95358d5..2a3c0f768 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -765,12 +765,13 @@ def ovs_checkpatch_parse(text, filename, author=None, committer=None):
-    for line in text.splitlines():
+    for line in re.split("\r?\n", text):
         if current_file != previous_file:
             previous_file = current_file
         lineno = lineno + 1
         total_line = total_line + 1
+        line = line.rstrip("\u2029\u2028\x85\x1e\x1d\x1c\x0c\x0b")
         if len(line) <= 0:

More information about the dev mailing list