On 05/08/2015 03:50 AM, Paolo Bonzini wrote:
> Right now, NBD includes potentially platform-specific error values in
> the wire protocol.
> 
> Luckily, most common error values are more or less universal: in
> particular, of all errno values <= 34 (up to ERANGE), they are all the
> same on supported platforms except for 11 (which is EAGAIN on Windows and
> Linux, but EDEADLK on Darwin and the *BSDs).  So, in order to guarantee
> some portability, only keep a handful of possible error codes and squash
> everything else to EINVAL.
> 

> +static int system_errno_to_nbd_errno(int err)
> +{
> +    switch (err) {
> +    case EPERM:
> +        return NBD_EPERM;
> +    case EIO:
> +        return NBD_EIO;
> +    case ENOMEM:
> +        return NBD_ENOMEM;
> +#ifdef EDQUOT
> +    case EDQUOT:
> +#endif
> +    case EFBIG:
> +    case ENOSPC:
> +        return NBD_ENOSPC;
> +    case EINVAL:
> +    default:
> +        return NBD_EINVAL;
> +    }

Do we also want to handle "case 0: return 0;" on either conversion, or
even "case 0: abort();" to ensure that callers are using these helpers
correctly?

But I can also live with it as is;
Reviewed-by: Eric Blake <ebl...@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to