[U-Boot] [PATCH v3 1/6] cmd: Migrate from_env() from pxe.c to nvedit.c

Patrice Chotard patrice.chotard at st.com
Mon Nov 25 08:07:36 UTC 2019


Migrate from_env() from pxe.c to nvedit.c as it's not pxe specific.

Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
---

 cmd/nvedit.c  | 17 +++++++++++++++++
 cmd/pxe.c     | 17 -----------------
 include/env.h | 10 ++++++++++
 3 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 99a3bc57b1..979def9c9c 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -680,6 +680,23 @@ char *env_get(const char *name)
 	return NULL;
 }
 
+/*
+ * Like env_get, but prints an error if envvar isn't defined in the
+ * environment.  It always returns what env_get does, so it can be used in
+ * place of env_get without changing error handling otherwise.
+ */
+char *from_env(const char *envvar)
+{
+	char *ret;
+
+	ret = env_get(envvar);
+
+	if (!ret)
+		printf("missing environment variable: %s\n", envvar);
+
+	return ret;
+}
+
 /*
  * Look up variable from environment for restricted C runtime env.
  */
diff --git a/cmd/pxe.c b/cmd/pxe.c
index 2059975446..2665c4f88d 100644
--- a/cmd/pxe.c
+++ b/cmd/pxe.c
@@ -37,23 +37,6 @@ const char *pxe_default_paths[] = {
 
 static bool is_pxe;
 
-/*
- * Like env_get, but prints an error if envvar isn't defined in the
- * environment.  It always returns what env_get does, so it can be used in
- * place of env_get without changing error handling otherwise.
- */
-static char *from_env(const char *envvar)
-{
-	char *ret;
-
-	ret = env_get(envvar);
-
-	if (!ret)
-		printf("missing environment variable: %s\n", envvar);
-
-	return ret;
-}
-
 #ifdef CONFIG_CMD_NET
 /*
  * Convert an ethaddr from the environment to the format used by pxelinux
diff --git a/include/env.h b/include/env.h
index b72239f6a5..d6c2d751d6 100644
--- a/include/env.h
+++ b/include/env.h
@@ -113,6 +113,16 @@ int env_match(unsigned char *name, int index);
  */
 char *env_get(const char *varname);
 
+/*
+ * Like env_get, but prints an error if envvar isn't defined in the
+ * environment.  It always returns what env_get does, so it can be used in
+ * place of env_get without changing error handling otherwise.
+ *
+ * @varname:	Variable to look up
+ * @return value of variable, or NULL if not found
+ */
+char *from_env(const char *envvar);
+
 /**
  * env_get_f() - Look up the value of an environment variable (early)
  *
-- 
2.17.1



More information about the U-Boot mailing list