From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] Use globalvar_add_simple_string for model and hostname
Date: Mon, 26 Feb 2018 08:55:36 +0100 [thread overview]
Message-ID: <20180226075536.21083-1-s.hauer@pengutronix.de> (raw)
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
reply other threads:[~2018-02-26 7:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180226075536.21083-1-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox