Skip to content

Commit

Permalink
devtools: fix check of variable declaration inside for
Browse files Browse the repository at this point in the history
An expression with a space is split by the awk script resulting in
false positive for any patch matching any of the two part of the
expression.
Fix this by using [[:space:]].

Fixes: 43e7348 ("devtools: forbid variable declaration inside for")

Signed-off-by: David Marchand <david.marchand@redhat.com>
  • Loading branch information
david-marchand authored and tmonjalo committed Jul 6, 2020
1 parent 8d4a222 commit 4c4f839
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion devtools/checkpatches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ check_forbidden_additions() { # <patch>

# forbid variable declaration inside "for" loop
awk -v FOLDERS='.' \
-v EXPRESSIONS='for *\\((char|u?int|unsigned|s?size_t)' \
-v EXPRESSIONS='for[[:space:]]*\\((char|u?int|unsigned|s?size_t)' \
-v RET_ON_FAIL=1 \
-v MESSAGE='Declaring a variable inside for()' \
-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
Expand Down

0 comments on commit 4c4f839

Please sign in to comment.