[PATCH] nitro_enclaves: Fix implicit type conversion

From: Jiasheng Jiang
Date: Tue Oct 26 2021 - 05:45:34 EST


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@xxxxxxxxxxx>
---
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