[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v7 13/16] nbd: Refactor conversion to errno to silen
From: |
Eric Blake |
Subject: |
[Qemu-block] [PATCH v7 13/16] nbd: Refactor conversion to errno to silence checkpatch |
Date: |
Fri, 14 Oct 2016 13:33:15 -0500 |
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 <address@hidden>
---
v7: new patch
---
nbd/client.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/nbd/client.c b/nbd/client.c
index f5e4c74..c6da4c4 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 */
--
2.7.4
- [Qemu-block] [PATCH v7 05/16] nbd: Rename struct nbd_request and nbd_reply, (continued)
- [Qemu-block] [PATCH v7 05/16] nbd: Rename struct nbd_request and nbd_reply, Eric Blake, 2016/10/14
- [Qemu-block] [PATCH v7 06/16] nbd: Share common reply-sending code in server, Eric Blake, 2016/10/14
- [Qemu-block] [PATCH v7 10/16] nbd: Let client skip portions of server reply, Eric Blake, 2016/10/14
- [Qemu-block] [PATCH v7 07/16] nbd: Send message along with server NBD_REP_ERR errors, Eric Blake, 2016/10/14
- [Qemu-block] [PATCH v7 08/16] nbd: Share common option-sending code in client, Eric Blake, 2016/10/14
- [Qemu-block] [PATCH v7 09/16] nbd: Let server know when client gives up negotiation, Eric Blake, 2016/10/14
- [Qemu-block] [PATCH v7 11/16] nbd: Less allocation during NBD_OPT_LIST, Eric Blake, 2016/10/14
- [Qemu-block] [PATCH v7 14/16] nbd: Improve server handling of shutdown requests, Eric Blake, 2016/10/14
- [Qemu-block] [PATCH v7 12/16] nbd: Support shorter handshake, Eric Blake, 2016/10/14
- [Qemu-block] [PATCH v7 16/16] nbd: Implement NBD_CMD_WRITE_ZEROES on client, Eric Blake, 2016/10/14
- [Qemu-block] [PATCH v7 13/16] nbd: Refactor conversion to errno to silence checkpatch,
Eric Blake <=
- [Qemu-block] [PATCH v7 15/16] nbd: Implement NBD_CMD_WRITE_ZEROES on server, Eric Blake, 2016/10/14
- Re: [Qemu-block] [Qemu-devel] [PATCH v7 00/16] nbd: efficient write zeroes, Eric Blake, 2016/10/25
- Re: [Qemu-block] [PATCH v7 00/16] nbd: efficient write zeroes, Paolo Bonzini, 2016/10/27