lkml.org 
[lkml]   [2021]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@iscas.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@redhat.com>

Thanks,
Stefano

\
 
 \ /
  Last update: 2021-11-03 10:13    [W:0.041 / U:0.744 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site