[RFC PATCH 00/11] Tidy command option parsing and use it a bit

Tom Rini trini at konsulko.com
Fri May 15 23:43:05 CEST 2026


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.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260515/41c4ec9b/attachment.sig>


More information about the U-Boot mailing list