From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Rodrigo Alencar <455.rodrigo.alencar@gmail.com>
Cc: rodrigo.alencar@analog.com, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-doc@vger.kernel.org, Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v8 02/10] lib: kstrtox: add kstrntoull() helper
Date: Fri, 20 Mar 2026 14:24:08 +0200 [thread overview]
Message-ID: <ab08aHbudFWEtLi8@ashevche-desk.local> (raw)
In-Reply-To: <ixvzb5mni2lhz733f4fvvzhozmpezkx5s2q7sash3wv3u2g7ov@pgs6pve6kxrq>
On Fri, Mar 20, 2026 at 12:08:41PM +0000, Rodrigo Alencar wrote:
> On 26/03/20 01:50PM, Andy Shevchenko wrote:
> > On Fri, Mar 20, 2026 at 11:16:32AM +0000, Rodrigo Alencar wrote:
> > > On 26/03/04 10:02AM, Rodrigo Alencar wrote:
...
> > > could you provide more feedback here? Thanks!
> >
> > I don't know what new I can add here.
> >
> > My suggestion was (and still is) to have something in *_strtoull() family
> > with additional checks added, but no limitations on the input string (i.e.
> > no max_chars). If you look at the printf() code the max_chars was added
> > solely for scanf() and has no use otherwise (yes, I know about and aware
> > of initramfs case).
>
> but is it include/linux/kstrtox.h the right place for this?
Seems so, there simple_strto*() are declared.
> *_strtoull familly... then can we just expose simple_strntoull(), which is
> private to lib/vsprintf.c, by changing its prototype to expose a error return?
Why do you need that? I'm lost, sorry, I don't understand this big desire of
having that max_chars parameter.
> In my case the limitation on the input string is useful for the truncation of
> decimal places when parsing the fixed point value. It would avoid a 64-bit
> division.
How is it better than checking the returned end pointer? Just treat anything
that parses too many digits after dot as invalid input?
ret = ..._strtoull(..., &end, &result);
if (ret)
return ret; // overflow!
if (end - start > $YOUR_LIMIT)
return -EINVAL; // bad input
...process result...
...
Some (stupid) thoughts loudly. IIUC even if we implement '%g' in scanf(), it
wont help you as you want to have more precise values. Do I get it correct?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-03-20 12:24 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 13:27 [PATCH v8 00/10] ADF41513/ADF41510 PLL frequency synthesizers Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 01/10] dt-bindings: iio: frequency: add adf41513 Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 02/10] lib: kstrtox: add kstrntoull() helper Rodrigo Alencar via B4 Relay
2026-03-03 13:49 ` Andy Shevchenko
2026-03-03 14:16 ` Rodrigo Alencar
2026-03-04 10:02 ` Rodrigo Alencar
2026-03-20 11:16 ` Rodrigo Alencar
2026-03-20 11:50 ` Andy Shevchenko
2026-03-20 12:08 ` Rodrigo Alencar
2026-03-20 12:24 ` Andy Shevchenko [this message]
2026-03-20 12:41 ` Rodrigo Alencar
2026-03-20 14:17 ` Andy Shevchenko
2026-03-20 14:44 ` David Laight
2026-03-04 10:16 ` David Laight
2026-03-04 11:41 ` Rodrigo Alencar
2026-03-10 9:26 ` Rodrigo Alencar
2026-03-10 10:50 ` David Laight
2026-03-10 11:30 ` Rodrigo Alencar
2026-03-03 13:27 ` [PATCH v8 03/10] lib: test-kstrtox: add tests for kstrntoull() Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 04/10] iio: core: add fixed point parsing with 64-bit parts Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 05/10] iio: test: add kunit test for fixed-point parsing Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 06/10] iio: frequency: adf41513: driver implementation Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 07/10] iio: frequency: adf41513: handle LE synchronization feature Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 08/10] iio: frequency: adf41513: features on frequency change Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 09/10] docs: iio: add documentation for adf41513 driver Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 10/10] Documentation: ABI: testing: add common ABI file for iio/frequency Rodrigo Alencar via B4 Relay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ab08aHbudFWEtLi8@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=455.rodrigo.alencar@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=akpm@linux-foundation.org \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rodrigo.alencar@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox