[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v2 06/11] qemu: rename CheckSlot to SlotInUse



On 04/17/2013 01:00 PM, Ján Tomko wrote:
> Also change its return value from int to bool.
> ---
>  src/qemu/qemu_command.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> +static bool qemuDomainPCIAddressSlotInUse(qemuDomainPCIAddressSetPtr addrs,
> +                                          virDevicePCIAddressPtr addr)
>  {
> -    return addrs->used[addr->bus][addr->slot] ? -1 : 0;
> +    return addrs->used[addr->bus][addr->slot] ? true : false;

I'm not a fan of 'cond ? true : false' - it is overkill compared to
shorter things like '!!cond'.  C99 guarantees that 'return int' in a
bool function will return 0 or 1; but because we are using gnulib's
<stdbool.h>, we can't take that shortcut (gnulib's implementation of
stdbool on top of C89 compilers might return > 1, with potential
confusion downstream when you have a value out of range of bool).  But
what you have is is correct, so up to you if you go for a shorter
representation.

ACK.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]