mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 11:39:53 +00:00
nbd: Refactor conversion to errno to silence checkpatch
Checkpatch complains that 'return EINVAL' is usually wrong (since we tend to favor 'return -EINVAL'). But it is a false positive for nbd_errno_to_system_errno(). Since NBD may add future defined wire values, refactor the code to keep checkpatch happy. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1476469998-28592-14-git-send-email-eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
c203c59ad9
commit
8b34a9dbc3
20
nbd/client.c
20
nbd/client.c
@ -23,23 +23,31 @@
|
||||
|
||||
static int nbd_errno_to_system_errno(int err)
|
||||
{
|
||||
int ret;
|
||||
switch (err) {
|
||||
case NBD_SUCCESS:
|
||||
return 0;
|
||||
ret = 0;
|
||||
break;
|
||||
case NBD_EPERM:
|
||||
return EPERM;
|
||||
ret = EPERM;
|
||||
break;
|
||||
case NBD_EIO:
|
||||
return EIO;
|
||||
ret = EIO;
|
||||
break;
|
||||
case NBD_ENOMEM:
|
||||
return ENOMEM;
|
||||
ret = ENOMEM;
|
||||
break;
|
||||
case NBD_ENOSPC:
|
||||
return ENOSPC;
|
||||
ret = ENOSPC;
|
||||
break;
|
||||
default:
|
||||
TRACE("Squashing unexpected error %d to EINVAL", err);
|
||||
/* fallthrough */
|
||||
case NBD_EINVAL:
|
||||
return EINVAL;
|
||||
ret = EINVAL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Definitions for opaque data types */
|
||||
|
Loading…
Reference in New Issue
Block a user