[ovs-dev] [PATCH] checkpatch: Fix regexp for if, while, etc inside macros.

Ilya Maximets i.maximets at samsung.com
Fri Aug 9 12:05:55 UTC 2019


This allows to use a one-character expression inside the 'if'
statement and multiple spaces before the line continuation character.

Fixes false positive in case like this:

  #define MACRO(ARG)     \
      if (a) {           \
          do_work(ARG);  \
      }

Fixes: 16770c6d9179 ("checkpatch: support macro continuation")
Signed-off-by: Ilya Maximets <i.maximets at samsung.com>
---
 tests/checkpatch.at     | 5 +++++
 utilities/checkpatch.py | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/checkpatch.at b/tests/checkpatch.at
index f3b26dd34..fe21acdf2 100755
--- a/tests/checkpatch.at
+++ b/tests/checkpatch.at
@@ -230,6 +230,11 @@ try_checkpatch \
    "COMMON_PATCH_HEADER
     +     $ctr (first_run) { \\
     "
+
+try_checkpatch \
+   "COMMON_PATCH_HEADER
+    +     $ctr (a) {    \\
+    "
 done
 AT_CLEANUP
 
diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index de5061406..f8fa00e30 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -172,7 +172,7 @@ __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]\) { \\' %
+__regex_if_macros = re.compile(r'^ +(%s) \([\S]([\s\S]+[\S])*\) { +\\' %
                                __parenthesized_constructs)
 
 skip_leading_whitespace_check = False
-- 
2.17.1



More information about the dev mailing list