lkml.org 
[lkml]   [2020]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] x86/hyper-v: remove unnecessary conversions to bool
Date
Michael Kelley <mikelley@microsoft.com> writes:

> From: Vitaly Kuznetsov <vkuznets@redhat.com> Sent: Friday, January 10, 2020 4:00 AM
>>
>>
>> I'd suggest we get rid of bool functions completely instead, something
>> like (untested):
>
> Just curious: Why prefer returning a u16 instead of a bool? To avoid
> having to test 'ret' for zero in the return statements, or is there some
> broader reason?

Basically to preserve hypercall failure code and not hide it under 'false'.

>> - ipi_arg.cpu_mask);
>> - return ((ret == 0) ? true : false);
>> + return (u16)hv_do_fast_hypercall16(HVCALL_SEND_IPI, ipi_arg.vector,
>> + ipi_arg.cpu_mask);
>
> The cast to u16 seems a bit dangerous. The hypercall status code is indeed
> returned in the low 16 bits of the hypercall result value, so it works, and
> maybe that is why you suggested u16 as the function return value. But it
> is a non-obvious assumption.

This is not obvious, I agree, and we can create a wrapper for it but we
more or less must convert it to 'u16': uppper bits don't indicate a
failure (e.g. 'reps complete').

--
Vitaly

\
 
 \ /
  Last update: 2020-01-13 09:09    [W:0.052 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site