mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next v2] checkpatch: Add check for array allocator family argument order
@ 2022-11-04  7:05 Liao Chang
  2022-11-04  8:35 ` Lukas Bulwahn
  2022-11-04 17:08 ` Christophe JAILLET
  0 siblings, 2 replies; 8+ messages in thread
From: Liao Chang @ 2022-11-04  7:05 UTC (permalink / raw)
  To: apw, joe, dwaipayanray1, lukas.bulwahn
  Cc: linux-kernel, liaochang1, bagasdotme, pbonzini

These array allocator family are sometimes misused with the first and
second arguments switchted.

Same issue with calloc, kvcalloc, kvmalloc_array etc.

Bleat if sizeof is the first argument.

Link: https://lore.kernel.org/lkml/5374345c-7973-6a3c-d559-73bf4ac15079@redhat.com/
Signed-off-by: Liao Chang <liaochang1@huawei.com>
Acked-by: Joe Perches <joe@perches.com>
---
v2:
1. Acked-by Joe Perches.
2. Use lore links in Link tag.

---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1e5e66ae5a52..a9a9dc277cff 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7128,7 +7128,7 @@ sub process {
 		}
 
 # check for alloc argument mismatch
-		if ($line =~ /\b((?:devm_)?(?:kcalloc|kmalloc_array))\s*\(\s*sizeof\b/) {
+		if ($line =~ /\b((?:devm_)?((?:k|kv)?(calloc|malloc_array)(?:_node)?))\s*\(\s*sizeof\b/) {
 			WARN("ALLOC_ARRAY_ARGS",
 			     "$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr);
 		}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-11-07  1:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04  7:05 [PATCH -next v2] checkpatch: Add check for array allocator family argument order Liao Chang
2022-11-04  8:35 ` Lukas Bulwahn
2022-11-04 14:33   ` Joe Perches
2022-11-07  1:25   ` liaochang (A)
2022-11-04 17:08 ` Christophe JAILLET
2022-11-05 17:24   ` Joe Perches
2022-11-05 21:36     ` Christophe JAILLET
2022-11-07  1:25       ` liaochang (A)

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®