Re: [Libguestfs] [libnbd PATCH 5/8] states: Wire in a read callback

Richard W.M. Jones
Thu, 20 Jun 2019 08:34:29 -0000

On Mon, Jun 17, 2019 at 07:07:55PM -0500, Eric Blake
wrote:
> +        errno = nbd_internal_errno_of_nbd_error (error);
> +        set_error (errno, "server reported read failure at offset
0x%" PRIx64,
> +                   offset);
> +        if (cmd->cb.fn.read (cmd->cb.opaque, cmd->data + (offset
- cmd->offset),
> +                             0, offset, LIBNBD_READ_ERROR) == -1)

I understand that in the next commit the pread_callback callback
function is meant to read errno implicitly, and this is why you are
setting it before calling that callback here.  However I don't
understand why you didn't just pass this in as an extra (ie. explicit)
parameter?  As currently defined this will not work well in non-C
languages, because the generator and indeed those languages know
nothing about errno.

Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org