From: Alexey Dobriyan <adobriyan@gmail.com>
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org
Subject: [PATCH] block: cleanup kstrto*() usage
Date: Sun, 22 Nov 2020 15:26:24 +0300 [thread overview]
Message-ID: <20201122122624.GA92364@localhost.localdomain> (raw)
kstrto*() can ship return value directly if no additional
checks are to be done.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
block/blk-sysfs.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -33,11 +33,11 @@ queue_var_show(unsigned long var, char *page)
static ssize_t
queue_var_store(unsigned long *var, const char *page, size_t count)
{
+ unsigned int v;
int err;
- unsigned long v;
- err = kstrtoul(page, 10, &v);
- if (err || v > UINT_MAX)
+ err = kstrtouint(page, 10, &v);
+ if (err)
return -EINVAL;
*var = v;
@@ -47,15 +47,7 @@ queue_var_store(unsigned long *var, const char *page, size_t count)
static ssize_t queue_var_store64(s64 *var, const char *page)
{
- int err;
- s64 v;
-
- err = kstrtos64(page, 10, &v);
- if (err < 0)
- return err;
-
- *var = v;
- return 0;
+ return kstrtos64(page, 10, var);
}
static ssize_t queue_requests_show(struct request_queue *q, char *page)
reply other threads:[~2020-11-22 12:26 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=20201122122624.GA92364@localhost.localdomain \
--to=adobriyan@gmail.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.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