diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2020-11-23 17:14:30 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-11-24 09:47:32 +0100 |
commit | 1344966f25a03f0a0a092bbad50e1cce3a3cd310 (patch) | |
tree | 7d3739cf74b3c02115a5ba34a5de7bd7e1e25f90 /commands | |
parent | 1d6ac29259c2cd77fc2d57c1a243277a41b585a4 (diff) | |
download | barebox-1344966f25a03f0a0a092bbad50e1cce3a3cd310.tar.gz barebox-1344966f25a03f0a0a092bbad50e1cce3a3cd310.tar.xz |
commands: boot: fix error code/clean up behavior when not booting
The boot command won't boot if:
- There are no boot entries: we should still clean up before
returning an error
- A menu or list of found entries should be displayed: we should
exit with success
- We were doing a dry run: we should propagate the boot entry
boot method's exit code
Do the necessary.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/boot.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/commands/boot.c b/commands/boot.c index d7795bde72..18f4e36ec7 100644 --- a/commands/boot.c +++ b/commands/boot.c @@ -97,19 +97,16 @@ static int do_boot(int argc, char *argv[]) if (list_empty(&entries->entries)) { printf("Nothing bootable found\n"); - return COMMAND_ERROR; - } - - if (do_list) { - bootsources_list(entries); + ret = COMMAND_ERROR; goto out; } - if (do_menu) { + if (do_list) + bootsources_list(entries); + else if (do_menu) bootsources_menu(entries, timeout); - goto out; - } + ret = 0; out: bootentries_free(entries); free(freep); |