Skip to content

Commit

Permalink
checkpatch: introduce constants for the parse states
Browse files Browse the repository at this point in the history
It's just easier to read.  Should be no functional change.

Signed-off-by: Aaron Conole <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
apconole authored and blp committed Apr 1, 2018
1 parent 5dbf6b1 commit 6ed8068
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions utilities/checkpatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ def run_checks(current_file, line, lineno):

def ovs_checkpatch_parse(text, filename):
global print_file_name, total_line, checking_file

PARSE_STATE_HEADING = 0
PARSE_STATE_DIFF_HEADER = 1
PARSE_STATE_CHANGE_BODY = 2

lineno = 0
signatures = []
co_authors = []
Expand Down Expand Up @@ -400,18 +405,18 @@ def ovs_checkpatch_parse(text, filename):
continue

if checking_file:
parse = 2
parse = PARSE_STATE_CHANGE_BODY

if parse == 1:
if parse == PARSE_STATE_DIFF_HEADER:
match = hunks.match(line)
if match:
parse = parse + 1
parse = PARSE_STATE_CHANGE_BODY
current_file = match.group(2)[2:]
print_file_name = current_file
continue
elif parse == 0:
elif parse == PARSE_STATE_HEADING:
if scissors.match(line):
parse = parse + 1
parse = PARSE_STATE_DIFF_HEADER
if not skip_signoff_check:
if len(signatures) == 0:
print_error("No signatures found.")
Expand All @@ -430,7 +435,7 @@ def ovs_checkpatch_parse(text, filename):
print_error(
"Remove Gerrit Change-Id's before submitting upstream.")
print("%d: %s\n" % (lineno, line))
elif parse == 2:
elif parse == PARSE_STATE_CHANGE_BODY:
newfile = hunks.match(line)
if newfile:
current_file = newfile.group(2)[2:]
Expand Down

0 comments on commit 6ed8068

Please sign in to comment.