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

Re: [Libguestfs] [libnbd] Slight API inconsistency

On 7/11/19 9:23 AM, Martin Kletzander wrote:
> The callback (e.g. for `nbd_block_status`) now has a support for returning
> errors thanks to the last parameter (`int *error`), so it was switched to
> returning void.

No, the callback still returns int.  Where are you seeing it return
void, because that's wrong.  The documentation states that *error is
ignored except when the return is -1.

>  But that was not switched everywhere and some code
> expects it
> to return `int`.  Yet another inconsistency is in the debug callback,
> which is
> supposed to return `void`, I guess, but due to the way the generator is
> implemented it's defined to return `int` instead.

ALL callbacks (should) return int. Even when the return value is
ignored. And I don't think that's worth changing.

> So my question is, should all callbacks just return nothing and if there
> is a
> need for some information to get back they will just use a pointer to
> some data
> (like with the `int *error`)?  Or do we need different return types for
> callbacks and should `Callback` and `CallbackPersist` be defined as:
> `string * arg list * ret` ?

If we ever need a callback that returns void or something other than
int, we can worry about that later. But for now, ALL callbacks should be
returning int, and the documentation should then cover what that return
value influences (whether it is ignored, as in the debug callback, or
whether it controls the use of *error if -1).

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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