From: Joe Perches Date: Fri, 22 Feb 2013 00:44:18 +0000 (-0800) Subject: checkpatch: Add check for kcalloc argument order X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=5ce59ae0bcc0f0ad249d21560c9bb5f6061e62a8;p=openwrt%2Fstaging%2Fblogic.git 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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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 { "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); } +# check for alloc argument mismatch + if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) { + WARN("ALLOC_ARRAY_ARGS", + "$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr); + } + # check for multiple semicolons if ($line =~ /;\s*;\s*$/) { WARN("ONE_SEMICOLON",