Skip to contentSkip to conversation

staging: replace simple_strtoul with kstroul

PATCH In review Ameen Ali 2 participants 2 messages Feb 19, 2015 – Feb 20, 2015 Printk

lore
Share & tools
lore

Ameen Ali

author
#0 lore raw

PATCH 2/2 staging: replace simple_strtoul with kstroul

Replacing obsolete simple_stroul with kstroul

---
 kernel/printk/printk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/printk/printk.c +2 -2
index c06df7d..058302c 100644
@@ -518,7 +518,7 @@ struct devkmsg_user {
 static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *buf, *line;
-	int i;
+	unsigned long int i;
 	int level = default_message_loglevel;
 	int facility = 1;	/* LOG_USER */
 	size_t len = iocb->ki_nbytes;
@@ -549,7 +549,7 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
 	if (line[0] == '<') {
 		char *endp = NULL;
 
-		i = simple_strtoul(line+1, &endp, 10);
+		i = kstrtoul(line+1,10, &endp);
 		if (endp && endp[0] == '>') {
 			level = i & 7;
 			if (i >> 3)
Signature · 1 line
2.1.0
#1 lore raw
Quoted 1 line · On Fri, 20 Feb 2015 00:13:57 +0200 Ameen Ali <[email protected]> wrote:

Subject: [PATCH 2/2] staging: replace simple_strtoul with kstroul

This isn't a staging patch.

s/kstroul/kstrtoul/

Quoted 4 lines

Date: Fri, 20 Feb 2015 00:13:57 +0200
X-Mailer: git-send-email 2.1.0

Replacing obsolete simple_stroul with kstroul

s/kstroul/kstrtoul/

kernel/printk/printk.c struct devkmsg_user { · line 521

Quoted 8 lines
kernel/printk/printk.c +1 -1
@@ -518,7 +518,7 @@ struct devkmsg_user {
 static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *buf, *line;
-	int i;
+	unsigned long int i;

It would be better to move this definition so it is local to the if' loop where it is used. And to give it a meaningful name - using i' is lame.

kernel/printk/printk.c static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from) · line 555

Quoted 12 lines
kernel/printk/printk.c +1 -1
 	int level = default_message_loglevel;
 	int facility = 1;	/* LOG_USER */
 	size_t len = iocb->ki_nbytes;
@@ -549,7 +549,7 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
 	if (line[0] == '<') {
 		char *endp = NULL;
 
-		i = simple_strtoul(line+1, &endp, 10);
+		i = kstrtoul(line+1,10, &endp);
 		if (endp && endp[0] == '>') {
 			level = i & 7;
 			if (i >> 3)

The interfaces are different - kstrtoul() can return a negative errno. afaict we'll only have issues if someone tried to print "<>..", but this string is coming from userspace so we must be very paranoid.