summaryrefslogtreecommitdiff
path: root/common/env_common.c
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-12-11 22:16:22 -0600
committerTom Rini <trini@ti.com>2012-12-13 11:46:55 -0700
commitec8a252cd492a7a409d6912aebeff34bb9e1e1e1 (patch)
tree346bb7bedd1dfe13f531725e7e0edaa2d80df1a8 /common/env_common.c
parent7afcf3a55b5f484b3d3442053fae8186a3fb92d7 (diff)
downloadu-boot-imx-ec8a252cd492a7a409d6912aebeff34bb9e1e1e1.zip
u-boot-imx-ec8a252cd492a7a409d6912aebeff34bb9e1e1e1.tar.gz
u-boot-imx-ec8a252cd492a7a409d6912aebeff34bb9e1e1e1.tar.bz2
env: Use getenv_yesno() more generally
Move the getenv_yesno() to env_common.c and change most checks for 'y' or 'n' to use this helper. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'common/env_common.c')
-rw-r--r--common/env_common.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/common/env_common.c b/common/env_common.c
index a960aa8..067fe3f 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -81,6 +81,20 @@ const uchar *env_get_addr(int index)
return &default_environment[index];
}
+/*
+ * Read an environment variable as a boolean
+ * Return -1 if variable does not exist (default to true)
+ */
+int getenv_yesno(const char *var)
+{
+ char *s = getenv(var);
+
+ if (s == NULL)
+ return -1;
+ return (*s == '1' || *s == 'y' || *s == 'Y' || *s == 't' || *s == 'T') ?
+ 1 : 0;
+}
+
void set_default_env(const char *s)
{
int flags = 0;