qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, pbonzini@redhat.com, mreitz@redhat.com
Subject: [Qemu-devel] [PATCH v7 13/16] nbd: Refactor conversion to errno to silence checkpatch
Date: Fri, 14 Oct 2016 13:33:15 -0500	[thread overview]
Message-ID: <1476469998-28592-14-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1476469998-28592-1-git-send-email-eblake@redhat.com>

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>
---
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

  parent reply	other threads:[~2016-10-14 18:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-14 18:33 [Qemu-devel] [PATCH v7 00/16] nbd: efficient write zeroes Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 01/16] nbd: Add qemu-nbd -D for human-readable description Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 02/16] nbd: Treat flags vs. command type as separate fields Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 03/16] nbd: Rename NBDRequest to NBDRequestData Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 04/16] nbd: Rename NbdClientSession to NBDClientSession Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 05/16] nbd: Rename struct nbd_request and nbd_reply Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 06/16] nbd: Share common reply-sending code in server Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 07/16] nbd: Send message along with server NBD_REP_ERR errors Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 08/16] nbd: Share common option-sending code in client Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 09/16] nbd: Let server know when client gives up negotiation Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 10/16] nbd: Let client skip portions of server reply Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 11/16] nbd: Less allocation during NBD_OPT_LIST Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 12/16] nbd: Support shorter handshake Eric Blake
2016-10-14 18:33 ` Eric Blake [this message]
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 14/16] nbd: Improve server handling of shutdown requests Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 15/16] nbd: Implement NBD_CMD_WRITE_ZEROES on server Eric Blake
2016-10-14 18:33 ` [Qemu-devel] [PATCH v7 16/16] nbd: Implement NBD_CMD_WRITE_ZEROES on client Eric Blake
2016-10-25 16:13 ` [Qemu-devel] [PATCH v7 00/16] nbd: efficient write zeroes Eric Blake
2016-10-27 12:50 ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476469998-28592-14-git-send-email-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).