Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751763AbbD3LcQ (ORCPT ); Thu, 30 Apr 2015 07:32:16 -0400 Received: from mail-lb0-f182.google.com ([209.85.217.182]:36382 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750766AbbD3LcP (ORCPT ); Thu, 30 Apr 2015 07:32:15 -0400 MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 30 Apr 2015 14:32:14 +0300 Message-ID: Subject: Re: [PATCH 1/1 linux-next] exofs: convert simple_str to kstr From: Alexey Dobriyan To: fabf@skynet.be, ooo@electrozaur.com Cc: Linux Kernel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1728 Lines: 54 On Thu, Apr 30, 2015 at 2:06 PM, Alexey Dobriyan wrote: >> case Opt_pid: >> + { >> + int rc; >> + >> if (0 == match_strlcpy(str, &args[0], sizeof(str))) >> return -EINVAL; >> - opts->pid = simple_strtoull(str, NULL, 0); >> + rc = kstrtoull(str, 0, &opts->pid); >> + if (rc) >> + return rc; > > kstrto*() functions were designed for proc/sysfs/sysctl/debugfs/... > files accepting 1 value from shell: > > echo 42 >/proc/foo > > To keep this simplest usecase simple kstrto*() functions accept > one optional newline character before mandatory NUL. > But in mount option parsing newlines aren't supposed to be. > > I'll resend parse_integer() shortly which is better suited for such code > http://marc.info/?l=linux-kernel&m=142876674416451&w=4 It should be better: * strsep/match_token/match_*() doesn't support u64 type, * even if it did current code does useless copy: char str[32]; token = match_token(p, tokens, args); switch (token) { case Opt_pid: if (0 == match_strlcpy(str, &args[0], sizeof(str))) return -EINVAL; opts->pid = simple_strtoull(str, NULL, 0); With parse_integer() code would look like: case Opt_pid: rv = parse_integer(args[0].from, 0, &opts->pid); if (rv < 0) return rv; if (args[0].from[rv] != '\0') return -EINVAL; And if and when match_token interface will start verifying that integer occupies whole options wihout junk at the end, that second NUL check can be removed as well. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/