On 10/27/2011 05:57 PM, Roopa Prabhu wrote:
>
Also, looks like no where else in libvirt code we return errno. We only
print errno but always return -1. And the -ETIMEDOUT case in macvtap is an
exception, cause the upper layer requires the cause of this particular
error.
We have a few places that return -1 on most errors, 0 on normal success,
and -2 on timeout; that is, the < 0 check can filter out all
non-success, but callers that care about the particular failure can
compare against -1.
If all errors can map to errno, we do have some examples of API that
return -errno; but those tend to be lower level API (lots in
util/util.c, not so many elsewhere); it tends to be easier to return -1
and document if errno is set to a sane value on failure.
I don't mind changing everything to errno. But that seems to be
not the
convention. And I cant find a clean way to not return -ETIMEDOUT. I can
however return status of the command in an argument and return -1 for the
ETIMEDOUT case. I will do that unless you have other suggestions. Thanks.
Returning -1 and -errno in the same function doesn't work (since -1
would be ambiguous with EACCES, on some systems), but returning -1 vs.
-2 to distinguish timeout from normal errors is fine.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org