diff mbox

[ovs-dev,v2,2/8] checkpatch: common print_line

Message ID 20170426155500.11043-3-aconole@redhat.com
State Changes Requested
Headers show

Commit Message

Aaron Conole April 26, 2017, 3:54 p.m. UTC
With the new framework, print_line can be moved out to the checks
framework.

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 utilities/checkpatch.py | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index ddee7c8..14d4f53 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -200,9 +200,14 @@  def get_file_type_checks(filename):
 def run_checks(current_file, line, lineno):
     """Runs the various checks for the particular line.  This will take
        filename into account."""
+    print_line = False
     for check in get_file_type_checks(current_file):
         if check['check'](line):
             check['print'](lineno)
+            print_line = True
+
+    if print_line:
+        print("\n%s\n" % line)
 
 
 def ovs_checkpatch_parse(text):
@@ -258,7 +263,6 @@  def ovs_checkpatch_parse(text):
                 m = is_co_author.match(line)
                 co_authors.append(m.group(3))
         elif parse == 2:
-            print_line = False
             newfile = hunks.match(line)
             if newfile:
                 current_file = newfile.group(2)
@@ -283,26 +287,19 @@  def ovs_checkpatch_parse(text):
                 continue
             if (not current_file.endswith('.mk') and
                     not leading_whitespace_is_spaces(cmp_line)):
-                print_line = True
                 print_warning("Line has non-spaces leading whitespace",
                               lineno)
             run_checks(current_file, cmp_line, lineno)
             if trailing_whitespace_or_crlf(cmp_line):
-                print_line = True
                 print_warning("Line has trailing whitespace", lineno)
             if not if_and_for_whitespace_checks(cmp_line):
-                print_line = True
                 print_error("Improper whitespace around control block",
                             lineno)
             if not if_and_for_end_with_bracket_check(cmp_line):
-                print_line = True
                 print_error("Inappropriate bracing around statement", lineno)
             if pointer_whitespace_check(cmp_line):
-                print_line = True
                 print_error("Inappropriate spacing in pointer declaration",
                             lineno)
-            if print_line:
-                print("\n%s\n" % line)
     if __errors or __warnings:
         return -1
     return 0