Skip to content

Commit

Permalink
checkpatch: Add acheck for use of sizeof without parenthesis
Browse files Browse the repository at this point in the history
Kernel style uses parenthesis around sizeof.

Signed-off-by: Joe Perches <[email protected]>
Cc: Andy Whitcroft <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and torvalds committed Jul 31, 2012
1 parent 4a27319 commit 66c80b6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3265,6 +3265,12 @@ sub process {
"sizeof(& should be avoided\n" . $herecurr);
}

# check for sizeof without parenthesis
if ($line =~ /\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/) {
WARN("SIZEOF_PARENTHESIS",
"sizeof $1 should be sizeof($1)\n" . $herecurr);
}

# check for line continuations in quoted strings with odd counts of "
if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) {
WARN("LINE_CONTINUATIONS",
Expand Down

0 comments on commit 66c80b6

Please sign in to comment.