qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] 9pfs-proxy: -retval vs errno vs -1
@ 2015-03-04 21:26 Michael Tokarev
  2015-03-06  5:52 ` Aneesh Kumar K.V
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Tokarev @ 2015-03-04 21:26 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: qemu-devel, Anthony Liguori

Another interesting tidbit is in hw/9pfs/virtio-9p-proxy.c.

All filesystem methods use common v9fs_request() function,
which returns -errno.  So far so good.

Now, *all* places which call this function, does this:

    retval = v9fs_request(...);
    if (retval < 0) {
        errno = -retval;
    }
    return retval;

and *some* does this:

    retval = v9fs_request(...);
    if (retval < 0) {
        errno = -retval;
        retval = -1;
    }
    return retval;

So basically, *all* places sets errno in case of negative
return from v9fs_request(), but only some of them make the
return value to be -1 instead of original negative value.

So I've two questions here.

1. Why some filesystem methods return -1 while some return -errno?
2. Why can't v9fs_request() set errno itself?

Thanks,

/mjt

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] 9pfs-proxy: -retval vs errno vs -1
  2015-03-04 21:26 [Qemu-devel] 9pfs-proxy: -retval vs errno vs -1 Michael Tokarev
@ 2015-03-06  5:52 ` Aneesh Kumar K.V
  0 siblings, 0 replies; 2+ messages in thread
From: Aneesh Kumar K.V @ 2015-03-06  5:52 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: qemu-devel, Anthony Liguori

Michael Tokarev <mjt@tls.msk.ru> writes:

> Another interesting tidbit is in hw/9pfs/virtio-9p-proxy.c.
>
> All filesystem methods use common v9fs_request() function,
> which returns -errno.  So far so good.
>
> Now, *all* places which call this function, does this:
>
>     retval = v9fs_request(...);
>     if (retval < 0) {
>         errno = -retval;
>     }
>     return retval;
>
> and *some* does this:
>
>     retval = v9fs_request(...);
>     if (retval < 0) {
>         errno = -retval;
>         retval = -1;
>     }
>     return retval;

We should be able to drop that retval = -1;

-aneesh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-06  5:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-04 21:26 [Qemu-devel] 9pfs-proxy: -retval vs errno vs -1 Michael Tokarev
2015-03-06  5:52 ` Aneesh Kumar K.V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).