* [PATCH] checkpatch: Add check for kcalloc argument order
@ 2013-01-26 19:24 Joe Perches
0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2013-01-26 19:24 UTC (permalink / raw)
To: Andrew Morton; +Cc: Andy Whitcroft, LKML
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>
---
scripts/checkpatch.pl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9cec6dd..b7326af 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",
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-01-26 19:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-26 19:24 [PATCH] checkpatch: Add check for kcalloc argument order Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®