summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-06-17 10:04:34 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-06-21 12:33:33 +0200
commit58c7c027acc4ebf27ddd622001bafb596e8123cf (patch)
tree311129752324cecd955853de25f2f96034e48a96 /common
parentecd082ad21a1d07973f42adbd5f2a20a07fdc71f (diff)
downloadbarebox-58c7c027acc4ebf27ddd622001bafb596e8123cf.tar.gz
barebox-58c7c027acc4ebf27ddd622001bafb596e8123cf.tar.xz
treewide: Use pr_setenv() where appropriate
We now have pr_setenv() which is a setenv() variant that takes a format string. Use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/bootsource.c8
-rw-r--r--common/menutree.c9
2 files changed, 3 insertions, 14 deletions
diff --git a/common/bootsource.c b/common/bootsource.c
index 1f8d053a81..79dacfd1d0 100644
--- a/common/bootsource.c
+++ b/common/bootsource.c
@@ -113,16 +113,12 @@ void bootsource_set(enum bootsource src)
void bootsource_set_instance(int instance)
{
- char buf[32];
-
bootsource_instance = instance;
if (instance < 0)
- sprintf(buf, "unknown");
+ setenv("bootsource_instance","unknown");
else
- snprintf(buf, sizeof(buf), "%d", instance);
-
- setenv("bootsource_instance", buf);
+ pr_setenv("bootsource_instance", "%d", instance);
}
enum bootsource bootsource_get(void)
diff --git a/common/menutree.c b/common/menutree.c
index 7fa835a7fe..751350d754 100644
--- a/common/menutree.c
+++ b/common/menutree.c
@@ -34,14 +34,7 @@ static void menutree_action(struct menu *m, struct menu_entry *me)
static void setenv_bool(const char *var, bool val)
{
- const char *str;
-
- if (val)
- str = "1";
- else
- str = "0";
-
- setenv(var, str);
+ pr_setenv(var, "%d", val);
}
static void menutree_box(struct menu *m, struct menu_entry *me)