bootstd: Fix a few minor bugs
cover bootstd: Fix a few minor bugs
This series fixes a few bugs noticed recently:
- handling of certain command-line updates with 'bootflow cmdline'
- support for 'bootflow read' in ChromeOS
Simon Glass (2):
bootstd: Handle a few special cases in cmdline_set_arg()
bootstd: cros: Correct condition for read method
boot/bootflow.c | 5 +++-- boot/bootmeth_cros.c | 8 ++++---- test/boot/bootflow.c | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-)
Signature · 1 line
2.42.0.758.gaed0368e0e-goog
PATCH 1/2 bootstd: Handle a few special cases in cmdline_set_arg()
Two bugs have appeared:
- arguments can have an equals sign embedded in them, which must be considered part of the value
- arguments must fully match the name; partial matches should be ignored
Fix these and add a test to cover both.
---
boot/bootflow.c | 5 +++-- test/boot/bootflow.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-)
boot/bootflow.c +3 -2
@@ -752,7 +752,7 @@ int cmdline_set_arg(char *buf, int maxlen, const char *cmdline, in_quote = false;continue ; } -if (*p =='=' ) { +if (*p =='=' && !arg_end) { arg_end = p; val = p +1 ; }else if (*p =='"' ) {
@@ -788,7 +788,8 @@ int cmdline_set_arg(char *buf, int maxlen, const char *cmdline, }/* if this is the target arg, update it */ -if (!strncmp (from, set_arg, arg_end - from)) { +if (arg_end - from == set_arg_len && + !strncmp (from, set_arg, set_arg_len)) {if (!buf) {bool has_quote = val_end[-1 ] =='"' ;
test/boot/bootflow.c +20 -0
@@ -973,6 +973,26 @@ static int bootflow_cmdline(struct unit_test_state *uts) }BOOTSTD_TEST (bootflow_cmdline,0 ); +/* test a few special changes to a long command line */ +static int bootflow_cmdline_special (struct unit_test_state *uts) +{ +char buf[500 ]; +int pos; + +/* +* check handling of an argument which has an embedded '=', as well as +* handling of a argument which partially matches ("ro" and "root") +*/ +ut_asserteq (32 ,cmdline_set_arg ( + buf,sizeof (buf), +"loglevel=7 root=PARTUUID=d68352e3 rootwait ro noinitrd" , +"root" ,NULL , &pos)); +ut_asserteq_str ("loglevel=7 rootwait ro noinitrd" , buf); + +return 0 ; +} +BOOTSTD_TEST (bootflow_cmdline_special,0 ); +/* Test ChromiumOS bootmeth */ static int bootflow_cros (struct unit_test_state *uts) {
Signature · 1 line
2.42.0.758.gaed0368e0e-goog
Re: [PATCH 1/2] bootstd: Handle a few special cases in cmdline_set_arg()
Quoted 10 lines · Simon Glass
Two bugs have appeared:
- arguments can have an equals sign embedded in them, which must be considered part of the value
- arguments must fully match the name; partial matches should be ignoredFix these and add a test to cover both.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom
PATCH 2/2 bootstd: cros: Correct condition for read method
In reply to Simon GlassThis has a typo which makes the method inoperable. Correct it so that 'bootflow read' works correctly for ChromeOS.
---
boot/bootmeth_cros.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
boot/bootmeth_cros.c +4 -4
@@ -406,7 +406,7 @@ static int cros_read_file(struct udevice *dev, struct bootflow *bflow,return -ENOSYS ; } -#if CONFIG_IS_ENABLED (BOOSTD_FULL ) +#if CONFIG_IS_ENABLED (BOOTSTD_FULL )static int cros_read_all (struct udevice *dev,struct bootflow *bflow) {int ret;
@@ -419,7 +419,7 @@ static int cros_read_all(struct udevice *dev, struct bootflow *bflow) return 0; } -#endif /* BOOSTD_FULL */ +#endif /* BOOTSTD_FULL */ static int cros_boot (struct udevice *dev,struct bootflow *bflow) {
@@ -458,9 +458,9 @@ static struct bootmeth_ops cros_bootmeth_ops = { .read_bootflow = cros_read_bootflow, .read_file = cros_read_file, .boot = cros_boot, -#if CONFIG_IS_ENABLED (BOOSTD_FULL ) +#if CONFIG_IS_ENABLED (BOOTSTD_FULL ) .read_all = cros_read_all, -#endif /* BOOSTD_FULL */ +#endif /* BOOTSTD_FULL */ };static const struct udevice_id cros_bootmeth_ids[] = {
Signature · 1 line
2.42.0.758.gaed0368e0e-goog
Re: [PATCH 2/2] bootstd: cros: Correct condition for read method
Quoted 4 lines · Simon Glass
This has a typo which makes the method inoperable. Correct it so that 'bootflow read' works correctly for ChromeOS.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom