[PATCH 10/37] parse_integer: convert fs/cachefiles/

From: Alexey Dobriyan
Date: Fri May 08 2015 - 14:38:01 EST


Convert away from deprecated simple_strto*() interfaces.

Switch "unsigned long" to "unsigned int" where possible.
kstrto*() functions can't be used because of trailing "%" sign. :^)

Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx>
---
fs/cachefiles/daemon.c | 84 +++++++++++++++++++++++++++-----------------------
1 file changed, 45 insertions(+), 39 deletions(-)

diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index f601def..cc1a921 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -326,14 +326,15 @@ static int cachefiles_daemon_range_error(struct cachefiles_cache *cache,
*/
static int cachefiles_daemon_frun(struct cachefiles_cache *cache, char *args)
{
- unsigned long frun;
+ unsigned int frun;
+ int rv;

_enter(",%s", args);

- if (!*args)
- return -EINVAL;
-
- frun = simple_strtoul(args, &args, 10);
+ rv = parse_integer(args, 10, &frun);
+ if (rv < 0)
+ return rv;
+ args += rv;
if (args[0] != '%' || args[1] != '\0')
return -EINVAL;

@@ -350,14 +351,15 @@ static int cachefiles_daemon_frun(struct cachefiles_cache *cache, char *args)
*/
static int cachefiles_daemon_fcull(struct cachefiles_cache *cache, char *args)
{
- unsigned long fcull;
+ unsigned int fcull;
+ int rv;

_enter(",%s", args);

- if (!*args)
- return -EINVAL;
-
- fcull = simple_strtoul(args, &args, 10);
+ rv = parse_integer(args, 10, &fcull);
+ if (rv < 0)
+ return rv;
+ args += rv;
if (args[0] != '%' || args[1] != '\0')
return -EINVAL;

@@ -374,14 +376,15 @@ static int cachefiles_daemon_fcull(struct cachefiles_cache *cache, char *args)
*/
static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
{
- unsigned long fstop;
+ unsigned int fstop;
+ int rv;

_enter(",%s", args);

- if (!*args)
- return -EINVAL;
-
- fstop = simple_strtoul(args, &args, 10);
+ rv = parse_integer(args, 10, &fstop);
+ if (rv < 0)
+ return rv;
+ args += rv;
if (args[0] != '%' || args[1] != '\0')
return -EINVAL;

@@ -398,14 +401,15 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
*/
static int cachefiles_daemon_brun(struct cachefiles_cache *cache, char *args)
{
- unsigned long brun;
+ unsigned int brun;
+ int rv;

_enter(",%s", args);

- if (!*args)
- return -EINVAL;
-
- brun = simple_strtoul(args, &args, 10);
+ rv = parse_integer(args, 10, &brun);
+ if (rv < 0)
+ return rv;
+ args += rv;
if (args[0] != '%' || args[1] != '\0')
return -EINVAL;

@@ -422,14 +426,15 @@ static int cachefiles_daemon_brun(struct cachefiles_cache *cache, char *args)
*/
static int cachefiles_daemon_bcull(struct cachefiles_cache *cache, char *args)
{
- unsigned long bcull;
+ unsigned int bcull;
+ int rv;

_enter(",%s", args);

- if (!*args)
- return -EINVAL;
-
- bcull = simple_strtoul(args, &args, 10);
+ rv = parse_integer(args, 10, &bcull);
+ if (rv < 0)
+ return rv;
+ args += rv;
if (args[0] != '%' || args[1] != '\0')
return -EINVAL;

@@ -446,14 +451,15 @@ static int cachefiles_daemon_bcull(struct cachefiles_cache *cache, char *args)
*/
static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
{
- unsigned long bstop;
+ unsigned int bstop;
+ int rv;

_enter(",%s", args);

- if (!*args)
- return -EINVAL;
-
- bstop = simple_strtoul(args, &args, 10);
+ rv = parse_integer(args, 10, &bstop);
+ if (rv < 0)
+ return rv;
+ args += rv;
if (args[0] != '%' || args[1] != '\0')
return -EINVAL;

@@ -601,21 +607,21 @@ inval:
*/
static int cachefiles_daemon_debug(struct cachefiles_cache *cache, char *args)
{
- unsigned long mask;
+ unsigned int mask;
+ int rv;

_enter(",%s", args);

- mask = simple_strtoul(args, &args, 0);
- if (args[0] != '\0')
- goto inval;
-
+ rv = parse_integer(args, 0, &mask);
+ if (rv < 0)
+ return rv;
+ if (args[rv] != '\0') {
+ pr_err("debug command requires mask\n");
+ return -EINVAL;
+ }
cachefiles_debug = mask;
_leave(" = 0");
return 0;
-
-inval:
- pr_err("debug command requires mask\n");
- return -EINVAL;
}

/*
--
2.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/