diff options
author | Marek BehĂșn | 2021-10-22 15:47:25 +0200 |
---|---|---|
committer | Simon Glass | 2021-10-31 12:26:44 -0600 |
commit | 37f3758a250d4c590ffac671f100d9b5ec73b417 (patch) | |
tree | cca121da9f5283677ccfc3097b2711ddf298f463 /include | |
parent | c5cbbe35fd7b3d05273f4d3f273c9e613bd38d7d (diff) |
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/env_default.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/env_default.h b/include/env_default.h index a6724719eca..23430dc70d7 100644 --- a/include/env_default.h +++ b/include/env_default.h @@ -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 |