From: Bartosz Golaszewski Date: Thu, 24 Sep 2020 12:45:21 +0000 (+0200) Subject: samples: configfs: replace simple_strtoul() with kstrtoint() X-Git-Tag: v5.10-rc1~119^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b86ff67d5a28f3ac1479d99b8a687e7107c58ae6;p=thirdparty%2Fkernel%2Flinux.git samples: configfs: replace simple_strtoul() with kstrtoint() simple_strtoul() is deprecated. Use kstrtoint(). Signed-off-by: Bartosz Golaszewski Signed-off-by: Christoph Hellwig --- diff --git a/samples/configfs/configfs_sample.c b/samples/configfs/configfs_sample.c index 1af7cc965098d..7cf1d44c1e371 100644 --- a/samples/configfs/configfs_sample.c +++ b/samples/configfs/configfs_sample.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -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; } @@ -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; }