]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
checkpatch: Add acheck for use of sizeof without parenthesis
authorJoe Perches <joe@perches.com>
Sat, 21 Jul 2012 00:55:00 +0000 (10:55 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 25 Jul 2012 03:53:22 +0000 (13:53 +1000)
Kernel style uses parenthesis around sizeof.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
scripts/checkpatch.pl

index 7190f95bf3124a1335eedc543e62d53e4c927c0f..a7436227bed9754feaad29c0ab126c0ae80f27b2 100755 (executable)
@@ -3265,6 +3265,12 @@ sub process {
                             "sizeof(& should be avoided\n" . $herecurr);
                }
 
+# check for sizeof without parenthesis
+               if ($line =~ /\bsizeof\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",