[PATCH 1/2] boot: ignore all spaces between boot targets

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Sep 14 11:27:10 EDT 2020


Boot targets are split by space. strsep unlike strtok(_r) returns an
empty string for each pair of consecutive delimiters. Ignore this case.

Note that this changes behavior: previously both
	boot ''
	global.boot.default= boot

were identical to
	boot /env/boot

With this change, this is no longer the case.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 commands/boot.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/commands/boot.c b/commands/boot.c
index ad2d83a17912..d7795bde726b 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -76,6 +76,8 @@ static int do_boot(int argc, char *argv[])
 	entries = bootentries_alloc();
 
 	while ((name = next(&handle)) != NULL) {
+		if (!*name)
+			continue;
 		ret = bootentry_create_from_name(entries, name);
 		if (ret <= 0)
 			printf("Nothing bootable found on '%s'\n", name);
-- 
2.28.0




More information about the barebox mailing list