diff mbox series

block: cleanup kstrto*() usage

Message ID 20201122122624.GA92364@localhost.localdomain (mailing list archive)
State New, archived
Headers show
Series block: cleanup kstrto*() usage | expand

Commit Message

Alexey Dobriyan Nov. 22, 2020, 12:26 p.m. UTC
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(-)
diff mbox series

Patch

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