From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755249AbbDKPhI (ORCPT ); Sat, 11 Apr 2015 11:37:08 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:33939 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754489AbbDKPhD (ORCPT ); Sat, 11 Apr 2015 11:37:03 -0400 Date: Sat, 11 Apr 2015 18:36:59 +0300 From: Alexey Dobriyan To: Andrew Morton Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] Add parse_integer() (replacement for simple_strto*()) Message-ID: <20150411153659.GA24361@p183.telecom.by> References: <20150409152613.GA14850@p183.telecom.by> <20150409130247.18f3133c58b5ebc11f0f64d8@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150409130247.18f3133c58b5ebc11f0f64d8@linux-foundation.org> 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 On Thu, Apr 09, 2015 at 01:02:47PM -0700, Andrew Morton wrote: > On Thu, 9 Apr 2015 18:26:14 +0300 Alexey Dobriyan wrote: > > > kstrto*() and kstrto*_from_user() family of functions were added > > help with parsing one integer written as string to proc/sysfs/debugfs > > files and pass it elsewhere. But they have a limitation: string passed > > must end with \0 or \n\0. There are enough places where kstrto*() > > functions can't be used because of this limitation. Trivial example: > > parse "%u.%u". > > > > ... > > > > include/linux/kernel.h | 72 +++++++++++++++++++ > > lib/Makefile | 1 > > lib/kstrtox.c | 27 +------ > > lib/parse-integer.c | 180 +++++++++++++++++++++++++++++++++++++++++++++++++ > > 4 files changed, 257 insertions(+), 23 deletions(-) > > That's a lot of code for something which is almost the same as > kstrtofoo(). > > Can we hack up _kstrtoull() to optionally provide the new behaviour? > We could use the top bit of `base' to select the behaviour. Hmm, OK. I did it the opposite way, though. parse_integer() becomes core interface, kstrto*() become wrappers. Alexey