old mode 100644
new mode 100755
@@ -156,3 +156,226 @@ try_checkpatch \
"ERROR: Patch lacks author."
AT_CLEANUP
+
+AT_SETUP([checkpatch - parenthesized constructs])
+for ctr in 'if' 'while' 'switch'; do
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + $ctr (first_run) {
+ "
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + $ctr ( first_run) {
+ " \
+ "ERROR: Improper whitespace around control block
+ #8 FILE: A.c:1:
+ $ctr ( first_run) {
+"
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + $ctr (first_run ) {
+ " \
+ "ERROR: Inappropriate bracing around statement
+ #8 FILE: A.c:1:
+ $ctr (first_run ) {
+"
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + $ctr (first_run)
+ " \
+ "ERROR: Inappropriate bracing around statement
+ #8 FILE: A.c:1:
+ $ctr (first_run)
+"
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + $ctr(first_run)
+ " \
+ "ERROR: Improper whitespace around control block
+ #8 FILE: A.c:1:
+ $ctr(first_run)
+"
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + $ctr (first_run) { /* foo */
+ "
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + $ctr (first_run) { \\
+ "
+done
+AT_CLEANUP
+
+
+
+AT_SETUP([checkpatch - parenthesized constructs - for])
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + for (init; condition; increment) {
+ "
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + for ( init; condition; increment) {
+ " \
+ "ERROR: Improper whitespace around control block
+ #8 FILE: A.c:1:
+ for ( init; condition; increment) {
+"
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + for (init; condition; increment ) {
+ " \
+ "ERROR: Inappropriate bracing around statement
+ #8 FILE: A.c:1:
+ for (init; condition; increment ) {
+"
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + for (init; condition; increment)
+ " \
+ "ERROR: Inappropriate bracing around statement
+ #8 FILE: A.c:1:
+ for (init; condition; increment)
+"
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + for(init; condition; increment)
+ " \
+ "ERROR: Improper whitespace around control block
+ #8 FILE: A.c:1:
+ for(init; condition; increment)
+"
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + for (init; condition; increment) { /* foo */
+ "
+
+try_checkpatch \
+ "Author: A
+
+ Signed-off-by: A
+ ---
+ diff --git a/A.c b/A.c
+ index 0000000..1111111 100644
+ --- a/A.c
+ +++ b/A.c
+ @@ -1,1 +1,1 @@
+ + for (init; condition; increment) { \\
+ "
+
+AT_CLEANUP
@@ -163,6 +163,8 @@ __regex_has_xxx_mark = re.compile(r'.*xxx.*', re.IGNORECASE)
__regex_added_doc_rst = re.compile(
r'\ndiff .*Documentation/.*rst\nnew file mode')
__regex_empty_return = re.compile(r'\s*return;')
+__regex_if_macros = re.compile(r'^ +(%s) \([\S][\s\S]+[\S]\) { \\' %
+ __parenthesized_constructs)
skip_leading_whitespace_check = False
skip_trailing_whitespace_check = False
@@ -252,7 +254,9 @@ def if_and_for_end_with_bracket_check(line):
if __regex_is_for_if_single_line_bracket.search(line) is not None:
if not balanced_parens(line):
return True
- if __regex_ends_with_bracket.search(line) is None:
+
+ if __regex_ends_with_bracket.search(line) is None and \
+ __regex_if_macros.match(line) is None:
return False
if __regex_conditional_else_bracing.match(line) is not None:
return False