mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 13:43:28 +00:00
env: Use static_assert() to check if default_environment is too large
Check sizeof(default_environment) against ENV_SIZE in a static_assert() instead of runtime. Only check if !USE_HOSTCC (for in fw_env tool ENV_SIZE expands to a variable, and cannot be checked statically) nad !DEFAULT_ENV_INSTANCE_EMBEDDED, for in that case the default_environment variable is not set. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
c5cbbe35fd
commit
37f3758a25
2 changed files with 6 additions and 5 deletions
5
env/common.c
vendored
5
env/common.c
vendored
|
@ -247,11 +247,6 @@ char *env_get_default(const char *name)
|
|||
|
||||
void env_set_default(const char *s, int flags)
|
||||
{
|
||||
if (sizeof(default_environment) > ENV_SIZE) {
|
||||
puts("*** Error - default environment is too large\n\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (s) {
|
||||
if ((flags & H_INTERACTIVE) == 0) {
|
||||
printf("*** Warning - %s, "
|
||||
|
|
|
@ -121,3 +121,9 @@ const char default_environment[] = {
|
|||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined(USE_HOSTCC) && !defined(DEFAULT_ENV_INSTANCE_EMBEDDED)
|
||||
#include <env_internal.h>
|
||||
static_assert(sizeof(default_environment) <= ENV_SIZE,
|
||||
"Default environment is too large");
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue