summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@samsung.com>2017-07-14 13:57:22 +0300
committerRussell Bryant <russell@ovn.org>2017-07-26 16:42:09 -0400
commit81c2316f71784ee604805ddac52921e5b5d8461f (patch)
tree5b56d6c424d0995170281c6779af031bc0d68aa5 /utilities
parentbc03d850d62f0bedb50f6d607ae62eb1175036a0 (diff)
downloadopenvswitch-81c2316f71784ee604805ddac52921e5b5d8461f.tar.gz
checkpatch: Print results while checking HEAD and stdin.
Currently, result status printed only for patch files. It'll be nice to have results for other checking types. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Acked-by: Aaron Conole <aconole@redhat.com> Signed-off-by: Russell Bryant <russell@ovn.org>
Diffstat (limited to 'utilities')
-rwxr-xr-xutilities/checkpatch.py33
1 files changed, 25 insertions, 8 deletions
diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index fe266ac50..4a92890fb 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -63,6 +63,13 @@ def print_warning(message):
__warnings = __warnings + 1
+def reset_counters():
+ global __errors, __warnings
+
+ __errors = 0
+ __warnings = 0
+
+
# These are keywords whose names are normally followed by a space and
# something in parentheses (usually an expression) then a left curly brace.
#
@@ -323,6 +330,8 @@ def ovs_checkpatch_parse(text, filename):
is_gerrit_change_id = re.compile(r'(\s*(change-id: )(.*))$',
re.I | re.M | re.S)
+ reset_counters()
+
for line in text.split('\n'):
if current_file != previous_file:
previous_file = current_file
@@ -414,8 +423,16 @@ Check options:
% sys.argv[0])
+def ovs_checkpatch_print_result(result):
+ global __warnings, __errors, total_line
+ if result < 0:
+ print("Lines checked: %d, Warnings: %d, Errors: %d\n" %
+ (total_line, __warnings, __errors))
+ else:
+ print("Lines checked: %d, no obvious problems found\n" % (total_line))
+
+
def ovs_checkpatch_file(filename):
- global __warnings, __errors, checking_file, total_line
try:
mail = email.message_from_file(open(filename, 'r'))
except:
@@ -426,11 +443,7 @@ def ovs_checkpatch_file(filename):
if part.get_content_maintype() == 'multipart':
continue
result = ovs_checkpatch_parse(part.get_payload(decode=False), filename)
- if result < 0:
- print("Lines checked: %d, Warnings: %d, Errors: %d" %
- (total_line, __warnings, __errors))
- else:
- print("Lines checked: %d, no obvious problems found" % (total_line))
+ ovs_checkpatch_print_result(result)
return result
@@ -494,7 +507,9 @@ if __name__ == '__main__':
f.close()
print('== Checking %s ==' % revision)
- if ovs_checkpatch_parse(patch, revision):
+ result = ovs_checkpatch_parse(patch, revision)
+ ovs_checkpatch_print_result(result)
+ if result:
status = -1
sys.exit(status)
@@ -504,5 +519,7 @@ if __name__ == '__main__':
if sys.stdin.isatty():
usage()
sys.exit(-1)
- sys.exit(ovs_checkpatch_parse(sys.stdin.read(), '-'))
+ result = ovs_checkpatch_parse(sys.stdin.read(), '-')
+ ovs_checkpatch_print_result(result)
+ sys.exit(result)
sys.exit(ovs_checkpatch_file(filename))