Convert env export and import to use getopt()
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 6 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | cmd: nvedit: Use getopt() in env exportcmd/ cmd/ | +38 | 0 replies | |
| 2/2 | cmd: nvedit: Use getopt() in env importcmd/ cmd/ env/ | +46 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] Convert env export and import to use getopt()
U-Boot has had a getopt() implementation for over five years but it is not used much; most commands hand-roll their own argv loops to spot -x style flags. The env export and env import sub-commands have the gnarliest of these parsers in nvedit.c
Each one walks every -prefixed argv element by hand, opens an inner loop to split grouped flags and tracks a counter to catch a repeated format flag.
This short series converts both sub-commands to getopt(). The mutex check for the format flags is done after the option loop, since it is a per-command rule rather than an option-parsing rule, and the trailing positional list is read straight out of argv from gs.index onwards.
There is no functional change. getopt() stops at the first non-option, just as the hand-rolled loops did, so options still have to appear before the positional arguments.
Each command gains a 'select GETOPT' so the parser is linked in on boards that do not already enable it.
For firefly-rk3399:
03: cmd: nvedit: Use getopt() in env export
aarch64: (for 1/1 boards) all -45.0 rodata +27.0 text -72.0
04: cmd: nvedit: Use getopt() in env import
aarch64: (for 1/1 boards) all -27.0 rodata -55.0 text +28.0Simon Glass (2):
cmd: nvedit: Use getopt() in env export
cmd: nvedit: Use getopt() in env import
cmd/Kconfig | 2 + cmd/nvedit.c | 186 +++++++++++++++++++++++---------------------------- env/common.c | 2 +- 3 files changed, 85 insertions(+), 105 deletions(-)
---
base-commit: 87ed7fe45c76dd78094a2c9a4953676b4b7ace6e
branch: clid3
Signature · 1 line
2.43.0