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

Sean Anderson seanga2 at gmail.com
Fri May 15 23:59:41 CEST 2026


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


More information about the U-Boot mailing list