diff options
author | Joe Perches <joe@perches.com> | 2013-02-21 19:44:18 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-21 20:22:26 -0500 |
commit | 5ce59ae0bcc0f0ad249d21560c9bb5f6061e62a8 (patch) | |
tree | 1fa6ddc462a2425d6d8d50136330c2db0b6becee /scripts/checkpatch.pl | |
parent | e8eb3997ce2f5887472a674b32f295b0196ecf46 (diff) |
checkpatch: Add check for kcalloc argument order
kcalloc is sometimes misused with the first and second arguments switched.
Same issue with kmalloc_array too.
Bleat if sizeof is the first argument
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-x | scripts/checkpatch.pl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2c50eb4c4e66..7b40a3f729a7 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -3476,6 +3476,12 @@ sub process { | |||
3476 | "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); | 3476 | "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); |
3477 | } | 3477 | } |
3478 | 3478 | ||
3479 | # check for alloc argument mismatch | ||
3480 | if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) { | ||
3481 | WARN("ALLOC_ARRAY_ARGS", | ||
3482 | "$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr); | ||
3483 | } | ||
3484 | |||
3479 | # check for multiple semicolons | 3485 | # check for multiple semicolons |
3480 | if ($line =~ /;\s*;\s*$/) { | 3486 | if ($line =~ /;\s*;\s*$/) { |
3481 | WARN("ONE_SEMICOLON", | 3487 | WARN("ONE_SEMICOLON", |