Skip to contentSkip to conversation

staging: speakup: Replace simple_strtoul with kstrtoul

PATCH In review Bharath Vedartham 2 participants 3 messages Feb 23, 2019 Staging

lore
Share & tools
lore
#0 lore raw

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

simple_strtoul is obsolete. Change it to kstrtoul. Kernel is building and booting successfully.

---
 drivers/staging/speakup/kobjects.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/speakup/kobjects.c +3 -1
index 2e36d87..ad5a2b2 100644
@@ -787,7 +787,9 @@ static ssize_t message_store_helper(const char *buf, size_t count,
 			continue;
 		}
 
-		index = simple_strtoul(cp, &temp, 10);
+		retval = kstrtoul(cp, 0, &index);
+		if (retval)
+			return retval;
 
 		while ((temp < linefeed) && (*temp == ' ' || *temp == '\t'))
 			temp++;
Signature · 1 line
2.7.4
#1 lore raw

Bharath Vedartham, le dim. 24 févr. 2019 01:01:21 +0530, a ecrit:

Quoted 2 lines

simple_strtoul is obsolete. Change it to kstrtoul. Kernel is building and booting successfully.

Please recheck your patch, temp is used after the simple_strtoul call.

Samuel

#2 lore raw
Quoted 7 lines · Samuel Thibault

Bharath Vedartham, le dim. 24 févr. 2019 01:01:21 +0530, a ecrit:

Quoted 2 lines

simple_strtoul is obsolete. Change it to kstrtoul. Kernel is building and booting successfully.

Please recheck your patch, temp is used after the simple_strtoul call.

Samuel

Sorry about that. After some thought, I feel this is a special case in replacing simple_strtoul to kstrtoul. simple_strtoul can give back a pointer to the end of the parsed string, whereas kstrtoul does not give any thing of that kind. In our case, temp is the end of the parsed cp string.

To replace simple_strtoul to kstrtoul, we need to know the length of the unsigned long int returned and shift the cp pointer by that length to get temp. This might involve a bit of code refactoring.

Bharath