mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/3] commands: boot: fix error code/clean up behavior when not booting
Date: Mon, 23 Nov 2020 17:14:30 +0100	[thread overview]
Message-ID: <20201123161432.28064-1-a.fatoum@pengutronix.de> (raw)

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>
---
 commands/boot.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/commands/boot.c b/commands/boot.c
index d7795bde726b..18f4e36ec733 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);
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2020-11-23 16:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 16:14 Ahmad Fatoum [this message]
2020-11-23 16:14 ` [PATCH 2/3] commands: boot: display each list entry in a separate line Ahmad Fatoum
2020-11-23 16:14 ` [PATCH 3/3] commands: boot: include blspec path name in entry title Ahmad Fatoum
2020-11-24  8:47 ` [PATCH 1/3] commands: boot: fix error code/clean up behavior when not booting Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201123161432.28064-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox