* [PATCH] checkpatch: Improve ALLOC_ARRAY_ARGS test
@ 2021-04-16 15:58 Christophe JAILLET
2021-04-16 16:11 ` Joe Perches
0 siblings, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2021-04-16 15:58 UTC (permalink / raw)
To: apw, joe, dwaipayanray1, lukas.bulwahn
Cc: linux-kernel, kernel-janitors, Christophe JAILLET
The devm_ variant of 'kcalloc()' and 'kmalloc_array()' are not tested
Add the corresponding check.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
scripts/checkpatch.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 44b9dc330ac6..c778edfdbad7 100755
--- 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/) {
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);
}
# check for multiple semicolons
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] checkpatch: Improve ALLOC_ARRAY_ARGS test
2021-04-16 15:58 [PATCH] checkpatch: Improve ALLOC_ARRAY_ARGS test Christophe JAILLET
@ 2021-04-16 16:11 ` Joe Perches
2021-04-16 16:51 ` Christophe JAILLET
0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2021-04-16 16:11 UTC (permalink / raw)
To: Christophe JAILLET, apw, dwaipayanray1, lukas.bulwahn
Cc: linux-kernel, kernel-janitors
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
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] checkpatch: Improve ALLOC_ARRAY_ARGS test
2021-04-16 16:11 ` Joe Perches
@ 2021-04-16 16:51 ` Christophe JAILLET
2021-04-16 17:03 ` Joe Perches
0 siblings, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2021-04-16 16:51 UTC (permalink / raw)
To: Joe Perches, apw, dwaipayanray1, lukas.bulwahn
Cc: linux-kernel, kernel-janitors
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.
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] checkpatch: Improve ALLOC_ARRAY_ARGS test
2021-04-16 16:51 ` Christophe JAILLET
@ 2021-04-16 17:03 ` Joe Perches
2021-04-16 18:03 ` Christophe JAILLET
0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2021-04-16 17:03 UTC (permalink / raw)
To: Christophe JAILLET, apw, dwaipayanray1, lukas.bulwahn
Cc: linux-kernel, kernel-janitors
On Fri, 2021-04-16 at 18:51 +0200, Christophe JAILLET wrote:
> 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
> I'll send a V2.
>
> Thx for the feedback.
>
> CJ
>
> >
> > if ($line =~ /\b((?:devm_)?(?:kcalloc|kmalloc_array))\s*\*\s*sizeof\b/) {
The \* above should be \(.
I can't type and apparently I don't proofread either.
I offer the excuse that the * and ( are adjacent on my keyboard...
cheers, Joe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] checkpatch: Improve ALLOC_ARRAY_ARGS test
2021-04-16 17:03 ` Joe Perches
@ 2021-04-16 18:03 ` Christophe JAILLET
0 siblings, 0 replies; 5+ messages in thread
From: Christophe JAILLET @ 2021-04-16 18:03 UTC (permalink / raw)
To: Joe Perches, apw, dwaipayanray1, lukas.bulwahn
Cc: linux-kernel, kernel-janitors
Le 16/04/2021 à 19:03, Joe Perches a écrit :
> On Fri, 2021-04-16 at 18:51 +0200, Christophe JAILLET wrote:
>> 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
>> I'll send a V2.
>>
>> Thx for the feedback.
>>
>> CJ
>>
>>>
>>> if ($line =~ /\b((?:devm_)?(?:kcalloc|kmalloc_array))\s*\*\s*sizeof\b/) {
>
> The \* above should be \(.
>
Yes I've seen it when I tested the updated test case.
> I can't type and apparently I don't proofread either.
> I offer the excuse that the * and ( are adjacent on my keyboard...
>
Well, you should try with a French keyboard :)
Anyway, thanks for taking time for the update.
CJ
> cheers, Joe
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-04-16 18:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16 15:58 [PATCH] checkpatch: Improve ALLOC_ARRAY_ARGS test Christophe JAILLET
2021-04-16 16:11 ` Joe Perches
2021-04-16 16:51 ` Christophe JAILLET
2021-04-16 17:03 ` Joe Perches
2021-04-16 18:03 ` Christophe JAILLET
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).