From: Joe Perches <joe@perches.com>
To: Liao Chang <liaochang1@huawei.com>,
apw@canonical.com, dwaipayanray1@gmail.com,
lukas.bulwahn@gmail.com,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, bagasdotme@gmail.com, pbonzini@redhat.com
Subject: Re: [PATCH] checkpatch: Add check for array allocator family argument order
Date: Thu, 03 Nov 2022 21:09:55 -0700 [thread overview]
Message-ID: <780c6d84dc1a90fb29ea56541ccd7510d14086ba.camel@perches.com> (raw)
In-Reply-To: <20221104040020.16389-1-liaochang1@huawei.com>
On Fri, 2022-11-04 at 12:00 +0800, Liao Chang wrote:
> 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://lkml.org/lkml/2022/11/3/668
You might use the -next version of checkpatch on this and find out
it's generally better to use lore links like:
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>
cheers, Joe
> ---
> 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);
> }
prev parent reply other threads:[~2022-11-04 4:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 4:00 Liao Chang
2022-11-04 4:09 ` Joe Perches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=780c6d84dc1a90fb29ea56541ccd7510d14086ba.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=bagasdotme@gmail.com \
--cc=dwaipayanray1@gmail.com \
--cc=liaochang1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®