From: Sean Anderson <seanga2@gmail.com>
To: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de,
"Andrew Goodbody" <andrew.goodbody@linaro.org>,
"Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>,
"Casey Connolly" <casey.connolly@linaro.org>,
"Daniel Palmer" <daniel@thingy.jp>,
"Heiko Schocher" <hs@nabladev.com>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Hugo Villeneuve" <hvilleneuve@dimonoff.com>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Jerome Forissier" <jerome.forissier@arm.com>,
"Joe Hershberger" <joe.hershberger@ni.com>,
"Kory Maincent (TI.com)" <kory.maincent@bootlin.com>,
"Marek Vasut" <marek.vasut+renesas@mailbox.org>,
"Mattijs Korpershoek" <mkorpershoek@kernel.org>,
"Michal Simek" <michal.simek@amd.com>,
"Mikhail Kshevetskiy" <mikhail.kshevetskiy@iopsys.eu>,
"Patrice Chotard" <patrice.chotard@foss.st.com>,
"Peng Fan" <peng.fan@nxp.com>,
"Peter Robinson" <pbrobinson@gmail.com>,
"Quentin Schulz" <quentin.schulz@cherry.de>,
"Varadarajan Narayanan" <varadarajan.narayanan@oss.qualcomm.com>,
"Yao Zi" <me@ziyao.cc>
Subject: Re: [RFC PATCH 00/11] Tidy command option parsing and use it a bit
Date: Fri, 15 May 2026 18:06:38 -0400 [thread overview]
Message-ID: <aa023095-2b32-070f-ff43-1f6922918b51@gmail.com> (raw)
In-Reply-To: <15041974-8838-56b6-b9d5-250383ed2625@gmail.com>
On 5/15/26 17:59, Sean Anderson wrote:
> On 5/15/26 17:43, Tom Rini wrote:
>> On Fri, May 15, 2026 at 02:32:51PM -0600, Simon Glass wrote:
>>
>>> We have had getopt() for over five years but it is not much used. It is
>>> much easier to understand arg-parsing using getopt() and it avoids
>>> common errors. As the named maintainer I decided to look at how to make
>>> more use of it.
>>>
>>> So this series explores the impact of converting a few commands to use
>>> getopt() instead of ad-hoc parsing. It updates getopt() to handle flags
>>> anywhere in the cmdline and provides a few helpers to reduce
>>> boilerplate.
>>>
>>> The chosen commands are:
>>>
>>> - echo: very simple with no flags
>>> - hash: fairly simple with just one flag
>>> - env grep/export/import - fuller examples
>>>
>>> The series also adds a recommendation to use getopt() for new commands.
>>>
>>> To try to reduce the code-size increase, a lower-case function is added
>>> and called from a few places. The difference is fairly marginal.
>>>
>>> Overall, the result is not pretty (see below) with about a 1.1K size
>>> increase on arm64:
>>
>> I think that means this is a no-go, and you need to work out what might
>> lead to a much smaller growth here.
>>
>
> Unfortunately, the only way to get a size reduction is to convert as many
> commands as possible.
>
> --Sean
And to expand on this, you really only get a reduction for any given command
when there are several options being parsed already like in the nvedit stuff.
Since most U-Boot commands don't use options it will be difficult to get a
reduction even when converting most commands on a board.
That's why I used it for new commands where no one could complain that
I grew their board.
I think it would be nice for all u-boot commands to have proper option support
like in barebox, but it's a lot of effort.
--Sean
next prev parent reply other threads:[~2026-05-15 22:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 20:32 [RFC PATCH 00/11] Tidy command option parsing and use it a bit Simon Glass
2026-05-15 20:32 ` [RFC PATCH 01/11] lib: string: Add strlower() Simon Glass
2026-05-15 20:32 ` [RFC PATCH 02/11] cmd: ini: Use strlower() to normalise case Simon Glass
2026-05-15 20:32 ` [RFC PATCH 03/11] fs: fat: " Simon Glass
2026-05-15 20:32 ` [RFC PATCH 04/11] boot: pxe_utils: Use strlower() in get_string() Simon Glass
2026-05-15 20:32 ` [RFC PATCH 05/11] lib: getopt: Permute by default with inline reorder Simon Glass
2026-05-15 21:37 ` Sean Anderson
2026-05-20 20:42 ` Simon Glass
2026-05-15 20:32 ` [RFC PATCH 06/11] lib: getopt: Add getopt_pop() helper Simon Glass
2026-05-15 21:40 ` Sean Anderson
2026-05-20 20:41 ` Simon Glass
2026-05-15 20:32 ` [RFC PATCH 07/11] cmd: echo: Use getopt() with '+' prefix for option parsing Simon Glass
2026-05-15 21:58 ` Sean Anderson
2026-05-20 20:41 ` Simon Glass
2026-05-15 20:32 ` [RFC PATCH 08/11] cmd: hash: Use getopt() " Simon Glass
2026-05-15 20:33 ` [RFC PATCH 09/11] cmd: nvedit: Use getopt() in env grep Simon Glass
2026-05-15 20:33 ` [RFC PATCH 10/11] cmd: nvedit: Use getopt() in env export and env import Simon Glass
2026-05-15 20:33 ` [RFC PATCH 11/11] doc: commands: Recommend getopt() for option parsing Simon Glass
2026-05-15 21:43 ` [RFC PATCH 00/11] Tidy command option parsing and use it a bit Tom Rini
2026-05-15 21:59 ` Sean Anderson
2026-05-15 22:06 ` Sean Anderson [this message]
2026-05-15 22:21 ` Tom Rini
2026-05-15 22:27 ` Sean Anderson
2026-05-20 20:40 ` Simon Glass
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=aa023095-2b32-070f-ff43-1f6922918b51@gmail.com \
--to=seanga2@gmail.com \
--cc=andrew.goodbody@linaro.org \
--cc=benoit.thebaudeau@advansee.com \
--cc=casey.connolly@linaro.org \
--cc=daniel@thingy.jp \
--cc=hs@nabladev.com \
--cc=hvilleneuve@dimonoff.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jerome.forissier@arm.com \
--cc=joe.hershberger@ni.com \
--cc=kory.maincent@bootlin.com \
--cc=marek.vasut+renesas@mailbox.org \
--cc=me@ziyao.cc \
--cc=michal.simek@amd.com \
--cc=mikhail.kshevetskiy@iopsys.eu \
--cc=mkorpershoek@kernel.org \
--cc=patrice.chotard@foss.st.com \
--cc=pbrobinson@gmail.com \
--cc=peng.fan@nxp.com \
--cc=quentin.schulz@cherry.de \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=varadarajan.narayanan@oss.qualcomm.com \
--cc=xypron.glpk@gmx.de \
/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