summaryrefslogtreecommitdiff
path: root/common/cmd_nvedit.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/cmd_nvedit.c')
-rw-r--r--common/cmd_nvedit.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 3474bc60940..1f9c6742602 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -71,9 +71,6 @@ DECLARE_GLOBAL_DATA_PTR;
SPI_FLASH|NVRAM|MMC|FAT|REMOTE} or CONFIG_ENV_IS_NOWHERE
#endif
-#define XMK_STR(x) #x
-#define MK_STR(x) XMK_STR(x)
-
/*
* Maximum expected input data size for import command
*/
@@ -103,6 +100,7 @@ int get_env_id(void)
return env_id;
}
+#ifndef CONFIG_SPL_BUILD
/*
* Command interface: print one or all environment variables
*
@@ -196,6 +194,7 @@ static int do_env_grep(cmd_tbl_t *cmdtp, int flag,
return rcode;
}
#endif
+#endif /* CONFIG_SPL_BUILD */
/*
* Perform consistency checking before setting, replacing, or deleting an
@@ -213,6 +212,9 @@ int env_check_apply(const char *name, const char *oldval,
{
int console = -1;
+ /* Default value for NULL to protect string-manipulating functions */
+ newval = newval ? : "";
+
/* Check for console redirection */
if (strcmp(name, "stdin") == 0)
console = stdin;
@@ -237,10 +239,8 @@ int env_check_apply(const char *name, const char *oldval,
if (console_assign(console, newval) < 0)
return 1;
-#ifdef CONFIG_SERIAL_MULTI
if (serial_assign(newval) < 0)
return 1;
-#endif
#endif /* CONFIG_CONSOLE_MUX */
}
@@ -254,7 +254,7 @@ int env_check_apply(const char *name, const char *oldval,
if (strcmp(name, "serial#") == 0 ||
(strcmp(name, "ethaddr") == 0
#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
- && strcmp(oldval, MK_STR(CONFIG_ETHADDR)) != 0
+ && strcmp(oldval, __stringify(CONFIG_ETHADDR)) != 0
#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
)) {
printf("Can't overwrite \"%s\"\n", name);
@@ -437,6 +437,7 @@ int setenv_addr(const char *varname, const void *addr)
return setenv(varname, str);
}
+#ifndef CONFIG_SPL_BUILD
int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
if (argc < 2)
@@ -536,6 +537,7 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return setenv(argv[1], buffer);
}
#endif /* CONFIG_CMD_EDITENV */
+#endif /* CONFIG_SPL_BUILD */
/*
* Look up variable from environment,
@@ -621,6 +623,7 @@ ulong getenv_ulong(const char *name, int base, ulong default_val)
return str ? simple_strtoul(str, NULL, base) : default_val;
}
+#ifndef CONFIG_SPL_BUILD
#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
@@ -635,6 +638,7 @@ U_BOOT_CMD(
""
);
#endif
+#endif /* CONFIG_SPL_BUILD */
/*
@@ -646,6 +650,9 @@ U_BOOT_CMD(
*/
int envmatch(uchar *s1, int i2)
{
+ if (s1 == NULL)
+ return -1;
+
while (*s1 == env_get_char(i2++))
if (*s1++ == '=')
return i2;
@@ -656,6 +663,7 @@ int envmatch(uchar *s1, int i2)
return -1;
}
+#ifndef CONFIG_SPL_BUILD
static int do_env_default(cmd_tbl_t *cmdtp, int __flag,
int argc, char * const argv[])
{
@@ -1114,3 +1122,4 @@ U_BOOT_CMD_COMPLETE(
var_complete
);
#endif
+#endif /* CONFIG_SPL_BUILD */