Messages in this thread | | | Date | Wed, 27 Oct 2021 19:27:59 +0300 | Subject | Re: [PATCH] nitro_enclaves: Fix implicit type conversion | From | "Paraschiv, Andra-Irina" <> |
| |
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.
| |