2022-11-04 09:00:33

by Lukas Bulwahn

[permalink] [raw]
Subject: Re: [PATCH -next v2] checkpatch: Add check for array allocator family argument order

On Fri, Nov 4, 2022 at 8:08 AM Liao Chang <[email protected]> wrote:
>
> These array allocator family are sometimes misused with the first and
> second arguments switchted.

Just a nit:

s/switchted/switched/

But probably you actually mean "swapped". I think there is a slight
difference between the two words, "switched" and "swapped". And here
the arguments are swapped. Note: I am also not a native speaker.

For the implementation change:

Acked-by: Lukas Bulwahn <[email protected]>

How many new findings are now identified with this extended check on
linux-next? Could you run checkpatch on all files of linux-next and
share the new findings? Then we can do a quick scan if some instances
should be immediately fixed or some janitor should follow through with
such a task.

Lukas

>
> Same issue with calloc, kvcalloc, kvmalloc_array etc.
>
> Bleat if sizeof is the first argument.
>
> Link: https://lore.kernel.org/lkml/[email protected]/
> Signed-off-by: Liao Chang <[email protected]>
> Acked-by: Joe Perches <[email protected]>
> ---
> 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
>


2022-11-04 15:23:44

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH -next v2] checkpatch: Add check for array allocator family argument order

On Fri, 2022-11-04 at 09:35 +0100, Lukas Bulwahn wrote:
> On Fri, Nov 4, 2022 at 8:08 AM Liao Chang <[email protected]> wrote:
> >
> > These array allocator family are sometimes misused with the first and
> > second arguments switchted.
>
> Just a nit:
>
> s/switchted/switched/
>
> But probably you actually mean "swapped". I think there is a slight
> difference between the two words, "switched" and "swapped". And here
> the arguments are swapped. Note: I am also not a native speaker.
>
> For the implementation change:
>
> Acked-by: Lukas Bulwahn <[email protected]>
>
> How many new findings are now identified with this extended check on
> linux-next? Could you run checkpatch on all files of linux-next and
> share the new findings? Then we can do a quick scan if some instances
> should be immediately fixed or some janitor should follow through with
> such a task.

There are ~25.
It's fairly trivial Lukas and only cosmetic.

https://lore.kernel.org/lkml/[email protected]/