Skip to content

Commit 3965292

Browse files
Liao Changakpm00
authored andcommitted
checkpatch: add check for array allocator family argument order
These array allocator family are sometimes misused with the first and second arguments switched. Same issue with calloc, kvcalloc, kvmalloc_array etc. Bleat if sizeof is the first argument. Link: https://lore.kernel.org/lkml/[email protected]/ Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Liao Chang <[email protected]> Acked-by: Joe Perches <[email protected]> Cc: Lukas Bulwahn <[email protected]> Cc: Christophe JAILLET <[email protected]> Cc: Andy Whitcroft <[email protected]> Cc: Bagas Sanjaya <[email protected]> Cc: Dwaipayan Ray <[email protected]> Cc: Paolo Bonzini <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent d04bb08 commit 3965292

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/checkpatch.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7146,7 +7146,7 @@ sub process {
71467146
}
71477147

71487148
# check for alloc argument mismatch
7149-
if ($line =~ /\b((?:devm_)?(?:kcalloc|kmalloc_array))\s*\(\s*sizeof\b/) {
7149+
if ($line =~ /\b((?:devm_)?((?:k|kv)?(calloc|malloc_array)(?:_node)?))\s*\(\s*sizeof\b/) {
71507150
WARN("ALLOC_ARRAY_ARGS",
71517151
"$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr);
71527152
}

0 commit comments

Comments
 (0)