Skip to content

Commit

Permalink
samples: configfs: replace simple_strtoul() with kstrtoint()
Browse files Browse the repository at this point in the history
simple_strtoul() is deprecated. Use kstrtoint().

Signed-off-by: Bartosz Golaszewski <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
brgl authored and Christoph Hellwig committed Oct 7, 2020
1 parent 1b0d36e commit b86ff67
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions samples/configfs/configfs_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/configfs.h>
Expand Down Expand Up @@ -61,17 +62,11 @@ static ssize_t childless_storeme_store(struct config_item *item,
const char *page, size_t count)
{
struct childless *childless = to_childless(item);
unsigned long tmp;
char *p = (char *) page;

tmp = simple_strtoul(p, &p, 10);
if (!p || (*p && (*p != '\n')))
return -EINVAL;

if (tmp > INT_MAX)
return -ERANGE;
int ret;

childless->storeme = tmp;
ret = kstrtoint(page, 10, &childless->storeme);
if (ret)
return ret;

return count;
}
Expand Down Expand Up @@ -144,17 +139,11 @@ static ssize_t simple_child_storeme_store(struct config_item *item,
const char *page, size_t count)
{
struct simple_child *simple_child = to_simple_child(item);
unsigned long tmp;
char *p = (char *) page;

tmp = simple_strtoul(p, &p, 10);
if (!p || (*p && (*p != '\n')))
return -EINVAL;

if (tmp > INT_MAX)
return -ERANGE;
int ret;

simple_child->storeme = tmp;
ret = kstrtoint(page, 10, &simple_child->storeme);
if (ret)
return ret;

return count;
}
Expand Down

0 comments on commit b86ff67

Please sign in to comment.