public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paraschiv, Andra-Irina" <andraprs@amazon.com>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: <linux-kernel@vger.kernel.org>, <lexnv@amazon.com>,
	<alcioa@amazon.com>, Greg KH <gregkh@linuxfoundation.org>,
	Kamal Mostafa <kamal@canonical.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Stefano Garzarella <sgarzare@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	"Vitaly Kuznetsov" <vkuznets@redhat.com>,
	"ne-devel-upstream@amazon.com" <ne-devel-upstream@amazon.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH] nitro_enclaves: Fix implicit type conversion
Date: Wed, 27 Oct 2021 19:27:59 +0300	[thread overview]
Message-ID: <cc1abeaf-4ea1-0e89-4449-dd87cd321cc7@amazon.com> (raw)
In-Reply-To: <1635241504-2591251-1-git-send-email-jiasheng@iscas.ac.cn>



On 26/10/2021 12:45, Jiasheng Jiang wrote:
> 
> The variable 'cpu' is defined as unsigned int.
> However in the for_each_cpu, its value is assigned to -1.
> That doesn't make sense and in the cpumask_next() it is implicitly
> type conversed to int.
> It is universally accepted that the implicit type conversion is
> terrible.
> Also, having the good programming custom will set an example for
> others.
> Thus, it might be better to change the definition of 'cpu' from
> unsigned int to int.
> 
> Fixes: ff8a4d3 ("nitro_enclaves: Add logic for setting an enclave vCPU")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>   drivers/virt/nitro_enclaves/ne_misc_dev.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nitro_enclaves/ne_misc_dev.c
> index e21e1e8..38d1fd9 100644
> --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c
> +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c
> @@ -168,7 +168,7 @@ static bool ne_check_enclaves_created(void)
>   static int ne_setup_cpu_pool(const char *ne_cpu_list)
>   {
>          int core_id = -1;
> -       unsigned int cpu = 0;
> +       int cpu = 0;
>          cpumask_var_t cpu_pool;
>          unsigned int cpu_sibling = 0;
>          unsigned int i = 0;
> --
> 2.7.4
> 

Thank you for the patch. Can you please update the other occurrences in 
the same file e.g. when a local variable is used for the "for_each_cpu" 
loop.

Thanks,
Andra

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/virt/nitro_enclaves/ne_misc_dev.c#n171
[2] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/virt/nitro_enclaves/ne_misc_dev.c#n173
[3] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/virt/nitro_enclaves/ne_misc_dev.c#n377
[4] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/virt/nitro_enclaves/ne_misc_dev.c#n519
[5] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/virt/nitro_enclaves/ne_misc_dev.c#n565
[6] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/virt/nitro_enclaves/ne_misc_dev.c#n1020
[7] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/virt/nitro_enclaves/ne_misc_dev.c#n1363



Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.

  reply	other threads:[~2021-10-27 16:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26  9:45 [PATCH] nitro_enclaves: Fix implicit type conversion Jiasheng Jiang
2021-10-27 16:27 ` Paraschiv, Andra-Irina [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-10-28  2:41 Jiasheng Jiang

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=cc1abeaf-4ea1-0e89-4449-dd87cd321cc7@amazon.com \
    --to=andraprs@amazon.com \
    --cc=alcioa@amazon.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jiasheng@iscas.ac.cn \
    --cc=kamal@canonical.com \
    --cc=kvm@vger.kernel.org \
    --cc=lexnv@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ne-devel-upstream@amazon.com \
    --cc=pbonzini@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=vkuznets@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