[Spice-devel] [spice-server 2/2] red-parse-qxl: Change int/1/0 to bool/true/false

Christophe Fergeau cfergeau at redhat.com
Fri Mar 31 10:40:49 UTC 2017


On Fri, Mar 31, 2017 at 05:57:58AM -0400, Frediano Ziglio wrote:
> > 
> > The red_get_* methods in red-parse-qxl.c return a boolean, even though
> > their return type is an int, and they return 1/0. This commit changes
> > this to the more explicit bool/true/false.
> 
> Usually I prefer functions that succeed and return true, not false.
> With the current state looks like the functions are more returning
> an error code where (as usual) 0 means success.

Hmm I agree it's a bit odd. However, they only ever return 0 or 1, so
felt better to make that explicit, especially with

buf = (uint8_t *)memslot_get_virt(slots, qxl->attr.style,
                                          style_nseg * sizeof(QXLFIXED), group_id, &error);
if (error) {
    return error;
}

I can try reversing the conditions everywhere to return true on success/false
on error, but I suspect I'll get it wrong :)

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170331/7f2910e7/attachment.sig>


More information about the Spice-devel mailing list