mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-30 16:35:37 +00:00
cmd: Migrate from_env() from pxe.c to nvedit.c
Migrate from_env() from pxe.c to nvedit.c as it's not pxe specific. Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
This commit is contained in:
parent
bead4f2f2c
commit
1ac2cb9741
3 changed files with 27 additions and 17 deletions
17
cmd/nvedit.c
17
cmd/nvedit.c
|
@ -681,6 +681,23 @@ char *env_get(const char *name)
|
||||||
return NULL;
|
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.
|
* Look up variable from environment for restricted C runtime env.
|
||||||
*/
|
*/
|
||||||
|
|
17
cmd/pxe.c
17
cmd/pxe.c
|
@ -37,23 +37,6 @@ const char *pxe_default_paths[] = {
|
||||||
|
|
||||||
static bool is_pxe;
|
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
|
#ifdef CONFIG_CMD_NET
|
||||||
/*
|
/*
|
||||||
* Convert an ethaddr from the environment to the format used by pxelinux
|
* Convert an ethaddr from the environment to the format used by pxelinux
|
||||||
|
|
|
@ -113,6 +113,16 @@ int env_match(unsigned char *name, int index);
|
||||||
*/
|
*/
|
||||||
char *env_get(const char *varname);
|
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)
|
* env_get_f() - Look up the value of an environment variable (early)
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue