[PATCH 2/2] blspec: devicetree-overlay: don't warn on multiple delimiting spaces

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


strsep unlike strtok(_r) returns an empty string for each pair of
consecutive delimiters.
blspec_apply_oftree_overlay is not equipped to handle an empty
string and will attempt treating "abspath/" as device tree file.

Explicitly check for empty strings, so this doesn't happen.

Cc: Michael Tretter <m.tretter at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
Change is untested
---
 common/blspec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/blspec.c b/common/blspec.c
index 9e1036c8342c..ed66352d1107 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -109,8 +109,11 @@ static void blspec_apply_oftree_overlays(const char *overlays,
 
 	sep = freep = xstrdup(overlays);
 
-	while ((overlay = strsep(&sep, " ")))
+	while ((overlay = strsep(&sep, " "))) {
+		if (!*overlay)
+			continue;
 		blspec_apply_oftree_overlay(overlay, abspath, dryrun);
+	}
 
 	free(freep);
 }
-- 
2.28.0




More information about the barebox mailing list