lkml.org 
[lkml]   [2021]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] checkpatch: Improve ALLOC_ARRAY_ARGS test
From
Date
Le 16/04/2021 à 18:11, Joe Perches a écrit :
> On Fri, 2021-04-16 at 17:58 +0200, Christophe JAILLET wrote:
>> The devm_ variant of 'kcalloc()' and 'kmalloc_array()' are not tested
>> Add the corresponding check.
> []
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
>> @@ -7006,9 +7006,9 @@ 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/) {
>
> Perhaps nicer using
Indeed, much better.
I'll send a V2.

Thx for the feedback.

CJ

>
> 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);
>> + "$1$2 uses number as first arg, sizeof is generally wrong\n" . $herecurr);
>
> So there's only one capture group and this line doesn't need to be changed.
>
>
>

\
 
 \ /
  Last update: 2021-04-16 18:52    [W:0.041 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site