Skip to contentSkip to conversation

9pfs-proxy: -retval vs errno vs -1

Qemu-devel Michael Tokarev 2 participants 2 messages Mar 4, 2015 – Mar 6, 2015

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 13 lines · Michael Tokarev

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;
Quoted 8 lines

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