summaryrefslogtreecommitdiff
path: root/tools/patman/checkpatch.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-06-14 19:54:06 +0300
committerSimon Glass <sjg@chromium.org>2020-07-10 03:57:22 +0300
commit89fb8b75bce61c53867f80392cdef9cfc5dbc9cd (patch)
tree07bc1082015c019f5f0b8ce9059c4082dde2c97a /tools/patman/checkpatch.py
parent4148c20f533d908a4255c134601b335322a0d38f (diff)
downloadu-boot-89fb8b75bce61c53867f80392cdef9cfc5dbc9cd.tar.xz
patman: Decode output from the '--show-types' option
Collect the 'checkpatch type' from each error, warning and check. Provide this to patman and update the uclass test to use it. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman/checkpatch.py')
-rw-r--r--tools/patman/checkpatch.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index 98c63af1dd..07c3e2739a 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -38,7 +38,7 @@ def FindCheckPatch():
sys.exit('Cannot find checkpatch.pl - please put it in your ' +
'~/bin directory or use --no-check')
-def CheckPatch(fname, verbose=False):
+def CheckPatch(fname, verbose=False, show_types=False):
"""Run checkpatch.pl on a file.
Returns:
@@ -64,8 +64,10 @@ def CheckPatch(fname, verbose=False):
result.problems = []
chk = FindCheckPatch()
item = {}
- result.stdout = command.Output(chk, '--no-tree', fname,
- raise_on_error=False)
+ args = [chk, '--no-tree']
+ if show_types:
+ args.append('--show-types')
+ result.stdout = command.Output(*args, fname, raise_on_error=False)
#pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)
#stdout, stderr = pipe.communicate()
@@ -81,9 +83,10 @@ def CheckPatch(fname, verbose=False):
' checks, (\d+)')
re_ok = re.compile('.*has no obvious style problems')
re_bad = re.compile('.*has style problems, please review')
- re_error = re.compile('ERROR: (.*)')
- re_warning = re.compile(emacs_prefix + 'WARNING:(?:[A-Z_]+:)? (.*)')
- re_check = re.compile('CHECK: (.*)')
+ type_name = '([A-Z_]+:)?'
+ re_error = re.compile('ERROR:%s (.*)' % type_name)
+ re_warning = re.compile(emacs_prefix + 'WARNING:%s (.*)' % type_name)
+ re_check = re.compile('CHECK:%s (.*)' % type_name)
re_file = re.compile('#\d+: FILE: ([^:]*):(\d+):')
re_note = re.compile('NOTE: (.*)')
indent = ' ' * 6
@@ -129,13 +132,16 @@ def CheckPatch(fname, verbose=False):
check_match = re_check.match(line)
subject_match = line.startswith('Subject:')
if err_match:
- item['msg'] = err_match.group(1)
+ item['cptype'] = err_match.group(1)
+ item['msg'] = err_match.group(2)
item['type'] = 'error'
elif warn_match:
- item['msg'] = warn_match.group(1)
+ item['cptype'] = warn_match.group(1)
+ item['msg'] = warn_match.group(2)
item['type'] = 'warning'
elif check_match:
- item['msg'] = check_match.group(1)
+ item['cptype'] = check_match.group(1)
+ item['msg'] = check_match.group(2)
item['type'] = 'check'
elif file_match:
item['file'] = file_match.group(1)