mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] Use globalvar_add_simple_string for model and hostname
@ 2018-02-26  7:55 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2018-02-26  7:55 UTC (permalink / raw)
  To: Barebox List

Simplify the code by using globalvar_add_simple_string(), no functional
change intended.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/misc.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/common/misc.c b/common/misc.c
index 0888f1f4f6..665f72be7e 100644
--- a/common/misc.c
+++ b/common/misc.c
@@ -141,20 +141,15 @@ static char *model;
  */
 void barebox_set_model(const char *__model)
 {
-	if (IS_ENABLED(CONFIG_GLOBALVAR)) {
-		globalvar_add_simple("model", __model);
-	} else {
-		free(model);
-		model = xstrdup(__model);
-	}
+	globalvar_add_simple_string("model", &model);
+
+	free(model);
+	model = xstrdup(__model);
 }
 EXPORT_SYMBOL(barebox_set_model);
 
 const char *barebox_get_model(void)
 {
-	if (IS_ENABLED(CONFIG_GLOBALVAR))
-		return getenv("global.model");
-
 	return model;
 }
 EXPORT_SYMBOL(barebox_get_model);
@@ -170,19 +165,14 @@ static char *hostname;
  */
 void barebox_set_hostname(const char *__hostname)
 {
-	if (IS_ENABLED(CONFIG_GLOBALVAR)) {
-		globalvar_add_simple("hostname", __hostname);
-	} else {
-		free(hostname);
-		hostname = xstrdup(__hostname);
-	}
+	globalvar_add_simple_string("hostname", &hostname);
+
+	free(hostname);
+	hostname = xstrdup(__hostname);
 }
 
 const char *barebox_get_hostname(void)
 {
-	if (IS_ENABLED(CONFIG_GLOBALVAR))
-		return getenv("global.hostname");
-
 	return hostname;
 }
 EXPORT_SYMBOL(barebox_get_hostname);
-- 
2.16.1


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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-26  7:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-26  7:55 [PATCH] Use globalvar_add_simple_string for model and hostname Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox