Re: [PATCH v2] checkpatch: Improve ALLOC_ARRAY_ARGS test

2021-04-16 Thread Joe Perches
On Fri, 2021-04-16 at 19:57 +0200, Christophe JAILLET wrote:
> The devm_ variant of 'kcalloc()' and 'kmalloc_array()' are not tested
> Add the corresponding check.
> 
> Signed-off-by: Christophe JAILLET 
> ---
> v2: use a cleaner regex as proposed by Joe Perches

Acked-by: Joe Perches 

> ---
>  scripts/checkpatch.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 44b9dc330ac6..23697a6b1eaa 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -7006,7 +7006,7 @@ sub process {
>   }
>  
> 
>  # check for alloc argument mismatch
> - if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) {
> + if ($line =~ 
> /\b((?:devm_)?(?:kcalloc|kmalloc_array))\s*\(\s*sizeof\b/) {
>   WARN("ALLOC_ARRAY_ARGS",
>    "$1 uses number as first arg, sizeof is generally 
> wrong\n" . $herecurr);
>   }




[PATCH v2] checkpatch: Improve ALLOC_ARRAY_ARGS test

2021-04-16 Thread Christophe JAILLET
The devm_ variant of 'kcalloc()' and 'kmalloc_array()' are not tested
Add the corresponding check.

Signed-off-by: Christophe JAILLET 
---
v2: use a cleaner regex as proposed by Joe Perches
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 44b9dc330ac6..23697a6b1eaa 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7006,7 +7006,7 @@ sub process {
}
 
 # check for alloc argument mismatch
-   if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) {
+   if ($line =~ 
/\b((?:devm_)?(?:kcalloc|kmalloc_array))\s*\(\s*sizeof\b/) {
WARN("ALLOC_ARRAY_ARGS",
 "$1 uses number as first arg, sizeof is generally 
wrong\n" . $herecurr);
}
-- 
2.27.0