Messages in this thread | | | From | Vitaly Kuznetsov <> | Subject | RE: [PATCH] x86/hyper-v: remove unnecessary conversions to bool | Date | Mon, 13 Jan 2020 09:07:45 +0100 |
| |
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
| |