[PATCH] globalvar: When a globalvar is created with a NULL value, use empty string

Sascha Hauer s.hauer at pengutronix.de
Thu Nov 23 03:04:38 PST 2017


As a convenience for users of globalvar_add_simple_string() create an
empty value for the variable when passed a NULL pointer as value.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/globalvar.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/globalvar.c b/common/globalvar.c
index ee756e5140..1db6bd9a41 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -459,6 +459,9 @@ int globalvar_add_simple_string(const char *name, char **value)
 
 	globalvar_nv_sync(name);
 
+	if (!*value)
+		*value = xstrdup("");
+
 	return 0;
 }
 
-- 
2.11.0




More information about the barebox mailing list