Skip to contentSkip to conversation

staging: speakup: Replace simple_strtoul by kstrtoul

PATCH In review Shekhar Bhandakkar 4 participants 5 messages Apr 27, 2017 – May 22, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: speakup: Replace simple_strtoul by kstrtoul

The simple_strtoul function is obsolete.
This patch replaces it by kstrtoul.

---
 drivers/staging/speakup/kobjects.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/speakup/kobjects.c +4 -1
index ca85476..8b9ddb9 100644
@@ -127,6 +127,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
 	int do_characters = !strcmp(attr->attr.name, "characters");
 	size_t desc_length = 0;
 	int i;
+	int err;
 
 	spin_lock_irqsave(&speakup_info.spinlock, flags);
 	while (cp < end) {
@@ -153,7 +154,9 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
 			continue;
 		}
 
-		index = simple_strtoul(cp, &temp, 10);
+		err = kstrtoul(cp, 10, &index);
+		if (err)
+			return err;
 		if (index > 255) {
 			rejected++;
 			cp = linefeed + 1;
Signature · 1 line
2.7.4
#1 lore raw

drivers/staging/speakup/kobjects.c static ssize_t chars_chartab_store(struct kobject *kobj, · line 157

Quoted 9 lines · Shekhar Bhandakkar, on jeu. 27 avril 2017 22:10:32 +0530, wrote:

The simple_strtoul function is obsolete.
This patch replaces it by kstrtoul.

drivers/staging/speakup/kobjects.c +1 -1
@@ -153,7 +154,9 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
 			continue;
 		}
 
-		index = simple_strtoul(cp, &temp, 10);
+		err = kstrtoul(cp, 10, &index);

Again, that doesn't update the temp pointer, which is used below. So really NACK from me.

Samuel

#2 lore raw

PATCH 1/1 staging: speakup: Replace simple_strtoul by kstrtoul

In reply to Shekhar Bhandakkar

The simple_strtoul function is obsolete.
This patch replaces it with kstrtoul.

---
 drivers/staging/speakup/kobjects.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/staging/speakup/kobjects.c +5 -1
index ca85476..8a1ebe6 100644
@@ -127,6 +127,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
 	int do_characters = !strcmp(attr->attr.name, "characters");
 	size_t desc_length = 0;
 	int i;
+	int err;
 
 	spin_lock_irqsave(&speakup_info.spinlock, flags);
 	while (cp < end) {
@@ -153,7 +154,10 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
 			continue;
 		}
 
-		index = simple_strtoul(cp, &temp, 10);
+		temp = cp;
+		err = kstrtoul(temp, 10, &index);
+		if (err)
+			return err;
 		if (index > 255) {
 			rejected++;
 			cp = linefeed + 1;
Signature · 1 line
2.7.4
#3 lore raw
In reply to Shekhar Bhandakkar
Quoted 21 lines · Shekhar Bhandakkar

The simple_strtoul function is obsolete.
This patch replaces it with kstrtoul.

---
 drivers/staging/speakup/kobjects.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/staging/speakup/kobjects.c +1 -0
index ca85476..8a1ebe6 100644
@@ -127,6 +127,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
 	int do_characters = !strcmp(attr->attr.name, "characters");
 	size_t desc_length = 0;
 	int i;
+	int err;
 
 	spin_lock_irqsave(&speakup_info.spinlock, flags);
 	while (cp < end) {

drivers/staging/speakup/kobjects.c static ssize_t chars_chartab_store(struct kobject *kobj, · line 158

Quoted 6 lines
drivers/staging/speakup/kobjects.c +2 -1
@@ -153,7 +154,10 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
 			continue;
 		}
 
-		index = simple_strtoul(cp, &temp, 10);
+		temp = cp;
+		err = kstrtoul(temp, 10, &index);

I haven't looked at how temp is used, but I doubt that this is the correct fix, because it doesn't make the distinction between cp and temp meaningful. In my experience, all of the remaining uses of simple_strtoul cannot be converted to kstrtoul because they use the second argument of simple_strtoul in some important way. The checkpatch warning is more intended to suggest that people avoid adding new uses of simple_strtoul rather than an indication that it is possible to convert all the old ones.

In any case, when you make a change in a patch, it should becomes [PATCH v2] and under the --- you should explain what is new in the v2. In a case like this where the change is complex, above the --- you should also explain why all aspects of your change are correct, in particular about the corrcetness of the use of temp.

julia

Quoted 13 lines
drivers/staging/speakup/kobjects.c +2 -1
+		if (err)
+			return err;
 		if (index > 255) {
 			rejected++;
 			cp = linefeed + 1;
--

2.7.4

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to Shekhar Bhandakkar

I happened to search my gmail spam box for patches and found this.

Quoted 21 lines · Shekhar Bhandakkar

The simple_strtoul function is obsolete.
This patch replaces it with kstrtoul.

---
 drivers/staging/speakup/kobjects.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/staging/speakup/kobjects.c +1 -0
index ca85476..8a1ebe6 100644
@@ -127,6 +127,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
        int do_characters = !strcmp(attr->attr.name, "characters");
        size_t desc_length = 0;
        int i;
+       int err;
 
        spin_lock_irqsave(&speakup_info.spinlock, flags);
        while (cp < end) {

drivers/staging/speakup/kobjects.c static ssize_t chars_chartab_store(struct kobject *kobj, · line 160

Quoted 8 lines
drivers/staging/speakup/kobjects.c +4 -1
@@ -153,7 +154,10 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
                        continue;
                }
 
-               index = simple_strtoul(cp, &temp, 10);
+               temp = cp;
+               err = kstrtoul(temp, 10, &index);
+               if (err)
+                       return err;

This is buggy. "temp" is supposed to point to the end of the number.

regards,
dan carpenter