Skip to content

Commit

Permalink
scripts/checkpatch.pl: add WARN on sizeof(&foo)
Browse files Browse the repository at this point in the history
sizeof(&foo) is frequently an error.  Warn on its use.

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 Mar 6, 2010
1 parent 8493829 commit 8f53a9b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2572,6 +2572,11 @@ sub process {
WARN("plain inline is preferred over $1\n" . $herecurr);
}

# check for sizeof(&)
if ($line =~ /\bsizeof\s*\(\s*\&/) {
WARN("sizeof(& should be avoided\n" . $herecurr);
}

# check for new externs in .c files.
if ($realfile =~ /\.c$/ && defined $stat &&
$stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
Expand Down

0 comments on commit 8f53a9b

Please sign in to comment.