[PATCH] fixup! commands: implement new devlookup command

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Jun 30 06:26:36 PDT 2022


Propagate error correctly when writing into environment variable as
well. While at it, ensure we do return an error value.

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

diff --git a/commands/devlookup.c b/commands/devlookup.c
index 9599df7b10bc..ce4cf2e10f45 100644
--- a/commands/devlookup.c
+++ b/commands/devlookup.c
@@ -11,12 +11,12 @@
 
 static int report(const char *variable, const char *val)
 {
+	if (!val)
+		return -(errno ?: EINVAL);
+
 	if (variable)
 		return setenv(variable, val);
 
-	if (!val)
-		return -errno;
-
 	printf("%s\n", val);
 	return 0;
 }
-- 
2.30.2




More information about the barebox mailing list