lkml.org 
[lkml]   [2021]   [Oct]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] nitro_enclaves: Fix implicit type conversion
Date
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
\
 
 \ /
  Last update: 2021-10-26 11:45    [W:0.038 / U:1.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site