[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20211103091323.clvhuiaf7kwrbywy@steredhat>
Date: Wed, 3 Nov 2021 10:13:23 +0100
From: Stefano Garzarella <sgarzare@...hat.com>
To: Jiasheng Jiang <jiasheng@...as.ac.cn>
Cc: andraprs@...zon.com, lexnv@...zon.com, alcioa@...zon.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] nitro_enclaves: Fix implicit type conversion
On Fri, Oct 29, 2021 at 01:48:46AM +0000, Jiasheng Jiang wrote:
>The variable 'cpu' and 'cpu_sibling' are defined as unsigned int.
>However in the for_each_cpu, their values are assigned to -1.
>That doesn't make sense and in the cpumask_next() they are 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' and
>'cpu_sibling' from unsigned int to int.
>
>Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
>---
> drivers/virt/nitro_enclaves/ne_misc_dev.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
The for_each_cpu documentation explicitly says that unsigned is
supported and -1 is commonly used to refer to the value before 0 even
for unsigned.
However I have nothing against changing them to int.
Reviewed-by: Stefano Garzarella <sgarzare@...hat.com>
Thanks,
Stefano
Powered by blists - more mailing lists