[libvirt] [PATCH v2 06/11] qemu: rename CheckSlot to SlotInUse
Eric Blake
eblake at redhat.com
Wed Apr 17 22:36:40 UTC 2013
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130417/6d6b7247/attachment-0001.sig>
More information about the libvir-list
mailing list