mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "liaochang (A)" <liaochang1@huawei.com>
To: Paolo Bonzini <pbonzini@redhat.com>, <seanjc@google.com>,
	<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <hpa@zytor.com>
Cc: <x86@kernel.org>, <kvm@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, Joe Perches <joe@perches.com>
Subject: Re: [PATCH 2/2] KVM: x86: Fix a typo about the usage of kvcalloc()
Date: Fri, 4 Nov 2022 12:06:04 +0800	[thread overview]
Message-ID: <025f1f44-54fa-cc01-96e3-bf0b33d27365@huawei.com> (raw)
In-Reply-To: <5374345c-7973-6a3c-d559-73bf4ac15079@redhat.com>



在 2022/11/3 21:39, Paolo Bonzini 写道:
> On 11/3/22 02:17, Liao Chang wrote:
>> Swap the 1st and 2nd arguments to be consistent with the usage of
>> kvcalloc().
>>
>> Fixes: c9b8fecddb5b ("KVM: use kvcalloc for array allocations")
>> Signed-off-by: Liao Chang<liaochang1@huawei.com>
>> ---
>>   arch/x86/kvm/cpuid.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
>> index 7065462378e2..b33c18b142c2 100644
>> --- a/arch/x86/kvm/cpuid.c
>> +++ b/arch/x86/kvm/cpuid.c
>> @@ -1331,7 +1331,7 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
>>       if (sanity_check_entries(entries, cpuid->nent, type))
>>           return -EINVAL;
>>   -    array.entries = kvcalloc(sizeof(struct kvm_cpuid_entry2), cpuid->nent, GFP_KERNEL);
>> +    array.entries = kvcalloc(cpuid->nent, sizeof(struct kvm_cpuid_entry2), GFP_KERNEL);
>>       if (!array.entries)
>>           return -ENOMEM;
>>   
> 
> It doesn't make any difference, but scripts/checkpatch.pl checks it so
> let's fix the sole occurrence in KVM.
> 
> However, please send a patch to scripts/checkpatch.pl to include calloc(),
> kvmalloc_array and kvcalloc() in the matched functions:
> 
> # check for alloc argument mismatch
>                 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);
>                 }

I ready send a patch to enhance the checking for array allocator family,
please check out patch "checkpatch: Add check for array allocator family argument order".

Thanks.

> 
> 
> Paolo
> 
> 
> .

-- 
BR,
Liao, Chang

      reply	other threads:[~2022-11-04  4:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03  1:17 Liao Chang
2022-11-03  2:37 ` Bagas Sanjaya
2022-11-03  4:18   ` liaochang (A)
2022-11-03  5:21     ` Joe Perches
2022-11-03 13:39 ` Paolo Bonzini
2022-11-04  4:06   ` liaochang (A) [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=025f1f44-54fa-cc01-96e3-bf0b33d27365@huawei.com \
    --to=liaochang1@huawei.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=joe@perches.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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®