lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20150517122713.GA2537@p183.telecom.by>
Date:	Sun, 17 May 2015 15:27:13 +0300
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	axboe@...nel.dk
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] block: convert to kstrto*()

Convert block/ code away from deprecated simple_strto*() interfaces.

Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
---

 block/blk-integrity.c    |   14 ++++++++++----
 block/blk-timeout.c      |   25 ++++++++++++-------------
 block/cfq-iosched.c      |   15 ++++-----------
 block/deadline-iosched.c |   15 ++++-----------
 4 files changed, 30 insertions(+), 39 deletions(-)

--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -288,9 +288,12 @@ static ssize_t integrity_tag_size_show(struct blk_integrity *bi, char *page)
 static ssize_t integrity_verify_store(struct blk_integrity *bi,
 				      const char *page, size_t count)
 {
-	char *p = (char *) page;
-	unsigned long val = simple_strtoul(p, &p, 10);
+	unsigned long val;
+	int rv;
 
+	rv = kstrtoul(page, 10, &val);
+	if (rv < 0)
+		return rv;
 	if (val)
 		bi->flags |= BLK_INTEGRITY_VERIFY;
 	else
@@ -307,9 +310,12 @@ static ssize_t integrity_verify_show(struct blk_integrity *bi, char *page)
 static ssize_t integrity_generate_store(struct blk_integrity *bi,
 					const char *page, size_t count)
 {
-	char *p = (char *) page;
-	unsigned long val = simple_strtoul(p, &p, 10);
+	unsigned long val;
+	int rv;
 
+	rv = kstrtoul(page, 10, &val);
+	if (rv < 0)
+		return rv;
 	if (val)
 		bi->flags |= BLK_INTEGRITY_GENERATE;
 	else
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -50,20 +50,19 @@ ssize_t part_timeout_store(struct device *dev, struct device_attribute *attr,
 			   const char *buf, size_t count)
 {
 	struct gendisk *disk = dev_to_disk(dev);
+	struct request_queue *q = disk->queue;
 	int val;
-
-	if (count) {
-		struct request_queue *q = disk->queue;
-		char *p = (char *) buf;
-
-		val = simple_strtoul(p, &p, 10);
-		spin_lock_irq(q->queue_lock);
-		if (val)
-			queue_flag_set(QUEUE_FLAG_FAIL_IO, q);
-		else
-			queue_flag_clear(QUEUE_FLAG_FAIL_IO, q);
-		spin_unlock_irq(q->queue_lock);
-	}
+	int rv;
+
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	spin_lock_irq(q->queue_lock);
+	if (val)
+		queue_flag_set(QUEUE_FLAG_FAIL_IO, q);
+	else
+		queue_flag_clear(QUEUE_FLAG_FAIL_IO, q);
+	spin_unlock_irq(q->queue_lock);
 
 	return count;
 }
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -4486,15 +4486,6 @@ cfq_var_show(unsigned int var, char *page)
 	return sprintf(page, "%u\n", var);
 }
 
-static ssize_t
-cfq_var_store(unsigned int *var, const char *page, size_t count)
-{
-	char *p = (char *) page;
-
-	*var = simple_strtoul(p, &p, 10);
-	return count;
-}
-
 #define SHOW_FUNCTION(__FUNC, __VAR, __CONV)				\
 static ssize_t __FUNC(struct elevator_queue *e, char *page)		\
 {									\
@@ -4523,7 +4514,9 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
 {									\
 	struct cfq_data *cfqd = e->elevator_data;			\
 	unsigned int __data;						\
-	int ret = cfq_var_store(&__data, (page), count);		\
+	int ret = kstrtouint(page, 10, &__data);			\
+	if (ret < 0)							\
+		return ret;						\
 	if (__data < (MIN))						\
 		__data = (MIN);						\
 	else if (__data > (MAX))					\
@@ -4532,7 +4525,7 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
 		*(__PTR) = msecs_to_jiffies(__data);			\
 	else								\
 		*(__PTR) = __data;					\
-	return ret;							\
+	return count;							\
 }
 STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, UINT_MAX, 0);
 STORE_FUNCTION(cfq_fifo_expire_sync_store, &cfqd->cfq_fifo_expire[1], 1,
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -379,15 +379,6 @@ deadline_var_show(int var, char *page)
 	return sprintf(page, "%d\n", var);
 }
 
-static ssize_t
-deadline_var_store(int *var, const char *page, size_t count)
-{
-	char *p = (char *) page;
-
-	*var = simple_strtol(p, &p, 10);
-	return count;
-}
-
 #define SHOW_FUNCTION(__FUNC, __VAR, __CONV)				\
 static ssize_t __FUNC(struct elevator_queue *e, char *page)		\
 {									\
@@ -409,7 +400,9 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
 {									\
 	struct deadline_data *dd = e->elevator_data;			\
 	int __data;							\
-	int ret = deadline_var_store(&__data, (page), count);		\
+	int ret = kstrtoint(page, 10, &__data);				\
+	if (ret < 0)							\
+		return ret;						\
 	if (__data < (MIN))						\
 		__data = (MIN);						\
 	else if (__data > (MAX))					\
@@ -418,7 +411,7 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
 		*(__PTR) = msecs_to_jiffies(__data);			\
 	else								\
 		*(__PTR) = __data;					\
-	return ret;							\
+	return count;							\
 }
 STORE_FUNCTION(deadline_read_expire_store, &dd->fifo_expire[READ], 0, INT_MAX, 1);
 STORE_FUNCTION(deadline_write_expire_store, &dd->fifo_expire[WRITE], 0, INT_MAX, 1);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ