[Libguestfs] [libnbd] Slight API inconsistency

Eric Blake eblake at redhat.com
Thu Jul 11 14:35:02 UTC 2019


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190711/d0b41ac5/attachment.sig>


More information about the Libguestfs mailing list