public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: <dev@dpdk.org>
Subject: Re: [PATCH v12 1/3] cmdline: use C standard library as number parser
Date: Fri, 27 Feb 2026 11:46:29 +0100	[thread overview]
Message-ID: <a270d0a3-1eec-4485-8824-86555890a40d@intel.com> (raw)
In-Reply-To: <aaCBr2xw0PBAJz7S@bricha3-mobl1.ger.corp.intel.com>

On 2/26/2026 6:23 PM, Bruce Richardson wrote:
> On Thu, Feb 26, 2026 at 04:44:48PM +0000, Anatoly Burakov wrote:
>> Remove custom number parser and use C standard library instead. In order to
>> keep compatibility with earlier versions of the parser, we have to take
>> into account a couple of quirks:
>>
>> - We did not consider "negative" numbers to be valid for anything other
>>    than base-10 numbers, whereas C standard library does. Adjust the tests
>>    to match the new behavior.
>> - We did not consider numbers such as "+4" to be valid, whereas C
>>    standard library does. Adjust the tests to match the new behavior.
>> - C standard library's strtoull does not do range checks on negative
>>    numbers, so we have to parse knowingly-negative numbers as signed.
>> - Some C standard library versions do not support binary numbers, so we
>>    keep around the relevant parts of the custom parser in place to support
>>    them. However, since those libc versions that do support them also
>>    support them being negative, allow negative binary in our parser as well.
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>> ---
>>
>> Notes:
>>      v10 -> v11:
>>      - Fixed all checkpatch warnings
>>      
>>      v9 -> v10:
>>      - Fixed commit message not reflecting changes for v9
>>      - Reworked enum range check to avoid compile issues on some platforms
>>      
>>      v8 -> v9:
>>      - glibc 2.38 supports binary formats (0bxxxx and -0bxxxx) under certain conditions,
>>        so in order to ensure the same functionality on all glic versions, add support for
>>        positive and negative binary formats, and adjust tests accordingly
>>      
>>      v7 -> v8:
>>      - Added the commented-out out-of-bounds check back
>>      - Replaced debug print messages to ensure they don't attempt to
>>        index the num_help[] array (should fix compile errors)
>>      
>>      v5 -> v6:
>>      - Allowed more negative numbers (such as negative octals or hex)
>>      - Updated unit tests to check new cases
>>      - Small refactoring of code to reduce amount of noise
>>      - More verbose debug output
>>      
>>      v4 -> v5:
>>      - Added this commit
>>
>>   app/test/test_cmdline_num.c     |  34 ++-
>>   lib/cmdline/cmdline_parse_num.c | 421 ++++++++++++++++----------------
>>   2 files changed, 248 insertions(+), 207 deletions(-)
>>
> 
> While I realise there is some additional test content here, I'm surprised
> that replacing a custom number parser with the standard one doesn't
> actually result in any code saving. The code is as long as before!

We could've, if we didn't have to support binary numbers - most of the 
parser is left intact because not all libc versions support binary 
numbers. I mean, glibc 2.38 was released in 2023 so it's not even safe 
to assume every LTS distribution is on it, but more importantly other 
libc implementations (e.g. musl) don't support binary numbers, which is 
why we still need the binary parser.

> 
> However, code size is no reason not to accept this, so:
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 


-- 
Thanks,
Anatoly

      reply	other threads:[~2026-02-27 10:46 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-02 12:27 [PATCH v1 1/1] app/testpmd: add sleep command Anatoly Burakov
2025-05-02 12:37 ` Bruce Richardson
2025-05-02 14:35   ` Burakov, Anatoly
2025-05-02 14:43     ` Bruce Richardson
2025-05-02 15:33       ` Morten Brørup
2025-05-02 15:42 ` Stephen Hemminger
2025-05-06 12:36   ` Burakov, Anatoly
2025-05-06 13:08 ` [PATCH v2 1/2] cmdline: add floating point support Anatoly Burakov
2025-05-06 13:08   ` [PATCH v2 2/2] app/testpmd: add sleep command Anatoly Burakov
2025-05-06 13:38   ` [PATCH v2 1/2] cmdline: add floating point support Bruce Richardson
2025-05-07  9:02     ` Burakov, Anatoly
2025-05-07  9:50 ` [PATCH v3 " Anatoly Burakov
2025-05-07  9:50   ` [PATCH v3 2/2] app/testpmd: add sleep command Anatoly Burakov
2025-05-07  9:53   ` [PATCH v3 1/2] cmdline: add floating point support Burakov, Anatoly
2025-05-07 10:01 ` [PATCH v4 " Anatoly Burakov
2025-05-07 10:01   ` [PATCH v4 2/2] app/testpmd: add sleep command Anatoly Burakov
2025-05-07 10:35   ` [PATCH v4 1/2] cmdline: add floating point support Konstantin Ananyev
2025-05-07 11:06     ` Burakov, Anatoly
2025-05-07 12:24       ` Konstantin Ananyev
2025-05-07 14:06         ` Burakov, Anatoly
2025-05-07 15:22 ` [PATCH v5 1/3] cmdline: use C standard library as number parser Anatoly Burakov
2025-05-07 15:22   ` [PATCH v5 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-20 16:19     ` Stephen Hemminger
2025-05-21 12:17       ` Burakov, Anatoly
2025-05-21 14:05     ` Stephen Hemminger
2025-05-23 10:21       ` Burakov, Anatoly
2025-05-23 14:47         ` Stephen Hemminger
2025-05-07 15:22   ` [PATCH v5 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-08  7:27   ` [PATCH v5 1/3] cmdline: use C standard library as number parser Bruce Richardson
2025-05-08  8:35     ` Burakov, Anatoly
2025-05-08  9:53 ` [PATCH v6 " Anatoly Burakov
2025-05-08  9:53   ` [PATCH v6 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-08  9:53   ` [PATCH v6 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-08 10:01 ` [PATCH v7 1/3] cmdline: use C standard library as number parser Anatoly Burakov
2025-05-08 10:01   ` [PATCH v7 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-08 10:09     ` Burakov, Anatoly
2025-05-08 10:01   ` [PATCH v7 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-08 13:16 ` [PATCH v8 1/3] cmdline: use C standard library as number parser Anatoly Burakov
2025-05-08 13:16   ` [PATCH v8 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-08 13:16   ` [PATCH v8 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-09 13:02   ` [PATCH v8 1/3] cmdline: use C standard library as number parser Burakov, Anatoly
2025-05-09 13:08     ` Burakov, Anatoly
2025-05-09 13:27       ` Burakov, Anatoly
2025-05-09 13:39 ` [PATCH v9 " Anatoly Burakov
2025-05-09 13:39   ` [PATCH v9 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-09 13:39   ` [PATCH v9 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-09 13:42   ` [PATCH v9 1/3] cmdline: use C standard library as number parser Burakov, Anatoly
2025-05-09 14:41 ` [PATCH v10 " Anatoly Burakov
2025-05-09 14:41   ` [PATCH v10 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-09 14:41   ` [PATCH v10 3/3] app/testpmd: add sleep command Anatoly Burakov
2026-02-26 16:44 ` [PATCH v12 1/3] cmdline: use C standard library as number parser Anatoly Burakov
2026-02-26 16:44   ` [PATCH v12 2/3] cmdline: add floating point support Anatoly Burakov
2026-02-26 18:16     ` Bruce Richardson
2026-02-26 18:19     ` Stephen Hemminger
2026-02-27 11:00       ` Burakov, Anatoly
2026-04-05 16:22     ` Stephen Hemminger
2026-02-26 16:44   ` [PATCH v12 3/3] app/testpmd: add sleep command Anatoly Burakov
2026-02-26 18:19     ` Bruce Richardson
2026-04-05 16:48     ` Stephen Hemminger
2026-02-26 17:23   ` [PATCH v12 1/3] cmdline: use C standard library as number parser Bruce Richardson
2026-02-27 10:46     ` Burakov, Anatoly [this message]

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=a270d0a3-1eec-4485-8824-86555890a40d@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /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