From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752315AbbEBA7J (ORCPT ); Fri, 1 May 2015 20:59:09 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:37374 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751118AbbEBA7F (ORCPT ); Fri, 1 May 2015 20:59:05 -0400 Date: Sat, 2 May 2015 03:59:01 +0300 From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, dhowells@redhat.com Subject: [PATCH 08/10] fs/cachefiles/: convert to parse_integer() Message-ID: <20150502005901.GH21655@p183.telecom.by> References: <20150502004714.GA21655@p183.telecom.by> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150502004714.GA21655@p183.telecom.by> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- fs/cachefiles/daemon.c | 84 ++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 39 deletions(-) --- 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; } /*