aboutsummaryrefslogtreecommitdiff
path: root/nbd
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2016-10-14 13:33:15 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2016-11-02 09:28:56 +0100
commit8b34a9dbc3f2c0afe3450cb20b94cc30f450e77b (patch)
treee77e9f41f15c8fd58941b4f3e846b6006a5c287d /nbd
parentc203c59ad9dc677b27e00ba76d221fd7e93c1aa6 (diff)
downloadqemu-8b34a9dbc3f2c0afe3450cb20b94cc30f450e77b.zip
qemu-8b34a9dbc3f2c0afe3450cb20b94cc30f450e77b.tar.gz
qemu-8b34a9dbc3f2c0afe3450cb20b94cc30f450e77b.tar.bz2
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>
Diffstat (limited to 'nbd')
-rw-r--r--nbd/client.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/nbd/client.c b/nbd/client.c
index b29963b..7bdce53 100644
--- a/nbd/client.c
+++ b/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 */