mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Subject: [PATCH v2 2/3] startup: don't clobber original autoboot state
Date: Wed, 22 Apr 2020 09:35:16 +0200	[thread overview]
Message-ID: <20200422073517.64477-2-ahmad@a3f.at> (raw)
In-Reply-To: <20200422073517.64477-1-ahmad@a3f.at>

do_autoboot_countdown changes autoboot state if the user presses m for
menu or ctrl+c to abort during count down. This is an internal detail
and doesn't need to be reflected in the state of the global variable.

This will improve UX when exporting the variable in the follow-up
commit, because on a regular boot it $autoboot will expand to countdown
instead of abort/boot/menu dependent on prior user input.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
v1 -> v2:
  * New commit
---
 common/startup.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index 7373ba7d0cd3..bda782317697 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -195,7 +195,7 @@ static bool test_abort(void)
 #define INITFILE "/env/bin/init"
 #define MENUFILE "/env/menu/mainmenu"
 
-static enum autoboot_state autoboot_state = AUTOBOOT_COUNTDOWN;
+static enum autoboot_state global_autoboot_state = AUTOBOOT_COUNTDOWN;
 
 /**
  * set_autoboot_state - set the autoboot state
@@ -206,7 +206,7 @@ static enum autoboot_state autoboot_state = AUTOBOOT_COUNTDOWN;
  */
 void set_autoboot_state(enum autoboot_state autoboot)
 {
-	autoboot_state = autoboot;
+	global_autoboot_state = autoboot;
 }
 
 /**
@@ -222,6 +222,7 @@ void set_autoboot_state(enum autoboot_state autoboot)
  */
 enum autoboot_state do_autoboot_countdown(void)
 {
+	enum autoboot_state autoboot_state;
 	unsigned flags = CONSOLE_COUNTDOWN_EXTERN;
 	int ret;
 	struct stat s;
@@ -229,8 +230,8 @@ enum autoboot_state do_autoboot_countdown(void)
 	char *abortkeys = NULL;
 	unsigned char outkey;
 
-	if (autoboot_state != AUTOBOOT_COUNTDOWN)
-		return autoboot_state;
+	if (global_autoboot_state != AUTOBOOT_COUNTDOWN)
+		return global_autoboot_state;
 
 	menu_exists = stat(MENUFILE, &s) == 0;
 
-- 
2.20.1


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

  reply	other threads:[~2020-04-22  7:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22  7:35 [PATCH v2 1/3] startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWN Ahmad Fatoum
2020-04-22  7:35 ` Ahmad Fatoum [this message]
2020-04-22  7:35 ` [PATCH v2 3/3] startup: add $global.autoboot to make behavior configurable Ahmad Fatoum
2020-04-23  6:30 ` [PATCH v2 1/3] startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWN 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=20200422073517.64477-2-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --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