From: Leonardo Bras <leonardo@linux.ibm.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>
Cc: Leonardo Bras <leonardo@linux.ibm.com>,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] drivers/vhost : Removes unnecessary 'else' in vhost_copy_from_user
Date: Thu, 12 Dec 2019 18:15:39 -0300 [thread overview]
Message-ID: <20191212211539.34578-1-leonardo@linux.ibm.com> (raw)
There is no need for this else statement, given that if block will return.
This change is not supposed to change the output binary.
It reduces identation level on most lines in this function, and also
fixes an split string on vq_err().
Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
---
drivers/vhost/vhost.c | 50 +++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 26 deletions(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index f44340b41494..b23d1b74c32f 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -824,34 +824,32 @@ static int vhost_copy_from_user(struct vhost_virtqueue *vq, void *to,
if (!vq->iotlb)
return __copy_from_user(to, from, size);
- else {
- /* This function should be called after iotlb
- * prefetch, which means we're sure that vq
- * could be access through iotlb. So -EAGAIN should
- * not happen in this case.
- */
- void __user *uaddr = vhost_vq_meta_fetch(vq,
- (u64)(uintptr_t)from, size,
- VHOST_ADDR_DESC);
- struct iov_iter f;
- if (uaddr)
- return __copy_from_user(to, uaddr, size);
+ /* This function should be called after iotlb
+ * prefetch, which means we're sure that vq
+ * could be access through iotlb. So -EAGAIN should
+ * not happen in this case.
+ */
+ void __user *uaddr = vhost_vq_meta_fetch(vq,
+ (u64)(uintptr_t)from, size,
+ VHOST_ADDR_DESC);
+ struct iov_iter f;
- ret = translate_desc(vq, (u64)(uintptr_t)from, size, vq->iotlb_iov,
- ARRAY_SIZE(vq->iotlb_iov),
- VHOST_ACCESS_RO);
- if (ret < 0) {
- vq_err(vq, "IOTLB translation failure: uaddr "
- "%p size 0x%llx\n", from,
- (unsigned long long) size);
- goto out;
- }
- iov_iter_init(&f, READ, vq->iotlb_iov, ret, size);
- ret = copy_from_iter(to, size, &f);
- if (ret == size)
- ret = 0;
- }
+ if (uaddr)
+ return __copy_from_user(to, uaddr, size);
+
+ ret = translate_desc(vq, (u64)(uintptr_t)from, size, vq->iotlb_iov,
+ ARRAY_SIZE(vq->iotlb_iov),
+ VHOST_ACCESS_RO);
+ if (ret < 0) {
+ vq_err(vq, "IOTLB translation failure: uaddr %p size 0x%llx\n",
+ from, (unsigned long long)size);
+ goto out;
+ }
+ iov_iter_init(&f, READ, vq->iotlb_iov, ret, size);
+ ret = copy_from_iter(to, size, &f);
+ if (ret == size)
+ ret = 0;
out:
return ret;
--
2.23.0
next reply other threads:[~2019-12-12 21:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-12 21:15 Leonardo Bras [this message]
2019-12-18 5:53 ` [PATCH 1/1] drivers/vhost : Removes unnecessary 'else' in vhost_copy_from_user Jason Wang
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=20191212211539.34578-1-leonardo@linux.ibm.com \
--to=leonardo@linux.ibm.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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).