From: Pavel Machek <pavel@ucw.cz>
To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
kernel list <linux-kernel@vger.kernel.org>,
trivial@kernel.org
Subject: [PATCH] fs/userfaultfd: No need for gotos
Date: Sat, 6 Jun 2020 17:02:12 +0200 [thread overview]
Message-ID: <20200606150212.GA10177@amd> (raw)
[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]
No need for gotos when all the target does is return. In this case it
also avoids redundant variable assignments.
Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index e39fdec8a0b0..860db4fd28dc 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -1883,12 +1883,10 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx,
int ret;
__u64 features;
- ret = -EINVAL;
if (ctx->state != UFFD_STATE_WAIT_API)
- goto out;
- ret = -EFAULT;
+ return -EINVAL;
if (copy_from_user(&uffdio_api, buf, sizeof(uffdio_api)))
- goto out;
+ return -EFAULT;
features = uffdio_api.features;
ret = -EINVAL;
if (uffdio_api.api != UFFD_API || (features & ~UFFD_API_FEATURES))
@@ -1899,20 +1897,18 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx,
/* report all available features and ioctls to userland */
uffdio_api.features = UFFD_API_FEATURES;
uffdio_api.ioctls = UFFD_API_IOCTLS;
- ret = -EFAULT;
if (copy_to_user(buf, &uffdio_api, sizeof(uffdio_api)))
- goto out;
+ return -EFAULT;
ctx->state = UFFD_STATE_RUNNING;
/* only enable the requested features for this uffd context */
ctx->features = uffd_ctx_features(features);
- ret = 0;
-out:
- return ret;
+ return 0;
+
err_out:
memset(&uffdio_api, 0, sizeof(uffdio_api));
if (copy_to_user(buf, &uffdio_api, sizeof(uffdio_api)))
- ret = -EFAULT;
- goto out;
+ return -EFAULT;
+ return ret;
}
static long userfaultfd_ioctl(struct file *file, unsigned cmd,
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
reply other threads:[~2020-06-06 15:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200606150212.GA10177@amd \
--to=pavel@ucw.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=trivial@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).