[ovs-dev,v2] checkpatch: fix patch separator line regex
diff mbox series

Message ID 20180628004004.20311-1-aconole@redhat.com
State Accepted
Headers show
Series
  • [ovs-dev,v2] checkpatch: fix patch separator line regex
Related show

Commit Message

Aaron Conole June 28, 2018, 12:40 a.m. UTC
The separator line always starts with three dashes on a line, optionally
followed by either white-space, OR a single space and a filename.  The
regex would previously match on any three dashes in a row.  This means
that a patch (such as [1]) would trigger the parser state machine to
advance beyond the signed-off checks.

Now, bound the check only to use what git-mailinfo would use as a
separator.
   --- <filename>
   ---<sp>

1: https://mail.openvswitch.org/pipermail/ovs-dev/2018-June/348625.html

Fixes: c599d5ccf316 ("checkpatch.py: A simple script for finding patch issues")
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
v1->v2: Update the regex based on how git-mailinfo interprets the separator.

 utilities/checkpatch.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ben Pfaff July 3, 2018, 6:42 p.m. UTC | #1
On Wed, Jun 27, 2018 at 08:40:04PM -0400, Aaron Conole wrote:
> The separator line always starts with three dashes on a line, optionally
> followed by either white-space, OR a single space and a filename.  The
> regex would previously match on any three dashes in a row.  This means
> that a patch (such as [1]) would trigger the parser state machine to
> advance beyond the signed-off checks.
> 
> Now, bound the check only to use what git-mailinfo would use as a
> separator.
>    --- <filename>
>    ---<sp>
> 
> 1: https://mail.openvswitch.org/pipermail/ovs-dev/2018-June/348625.html
> 
> Fixes: c599d5ccf316 ("checkpatch.py: A simple script for finding patch issues")
> Signed-off-by: Aaron Conole <aconole@redhat.com>

Thanks, applied to master.

Patch
diff mbox series

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 5a6d5f5ff..f92971438 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -619,7 +619,7 @@  def ovs_checkpatch_parse(text, filename):
     parse = 0
     current_file = filename if checking_file else ''
     previous_file = ''
-    scissors = re.compile(r'^[\w]*---[\w]*')
+    seppatch = re.compile(r'^---([\w]*| \S+)$')
     hunks = re.compile('^(---|\+\+\+) (\S+)')
     hunk_differences = re.compile(
         r'^@@ ([0-9-+]+),([0-9-+]+) ([0-9-+]+),([0-9-+]+) @@')
@@ -652,7 +652,7 @@  def ovs_checkpatch_parse(text, filename):
                 print_file_name = current_file
             continue
         elif parse == PARSE_STATE_HEADING:
-            if scissors.match(line):
+            if seppatch.match(line):
                 parse = PARSE_STATE_DIFF_HEADER
                 if not skip_signoff_check:
                     if len(signatures) == 0: