From 6fc2799e9e08d990e073225143f6254c39c42baa Mon Sep 17 00:00:00 2001 From: Joe Stringer Date: Wed, 8 Mar 2017 09:54:06 -0800 Subject: [PATCH] checkpatch: Check for pointer whitespace. Signed-off-by: Joe Stringer Acked-by: Russell Bryant --- utilities/checkpatch.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py index 26eb5c32b9b..e7c1a9ba14b 100755 --- a/utilities/checkpatch.py +++ b/utilities/checkpatch.py @@ -68,6 +68,7 @@ def print_warning(message, lineno=None): re.compile(r'^ +(if|for|while) \(.*\)') __regex_ends_with_bracket = \ re.compile(r'[^\s]\) {(\s+/\*[\s\Sa-zA-Z0-9\.,\?\*/+-]*)?$') +__regex_ptr_declaration_missing_whitespace = re.compile(r'[a-zA-Z0-9]\*') skip_leading_whitespace_check = False skip_trailing_whitespace_check = False @@ -157,6 +158,12 @@ def balanced_parens(line): return True +def pointer_whitespace_check(line): + """Return TRUE if there is no space between a pointer name and the + asterisk that denotes this is a apionter type, ie: 'struct foo*'""" + return __regex_ptr_declaration_missing_whitespace.search(line) is not None + + def ovs_checkpatch_parse(text): global print_file_name lineno = 0 @@ -257,6 +264,10 @@ def ovs_checkpatch_parse(text): 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: