X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fenv_flags.c;h=3c50620cb34df8b527131d3809e4ce5cddf3ff12;hb=0e689a61929bdf15423e868bc242c1268bda7db9;hp=e682d8517890cca27d87d812244e16330071e783;hpb=d0f30211e9823694c1c2c79f471dbe9d498a40fd;p=u-boot diff --git a/common/env_flags.c b/common/env_flags.c index e682d85178..3c50620cb3 100644 --- a/common/env_flags.c +++ b/common/env_flags.c @@ -11,10 +11,12 @@ #ifdef USE_HOSTCC /* Eliminate "ANSI does not permit..." warnings */ #include #include +#include "fw_env_private.h" #include "fw_env.h" #include #include #define getenv fw_getenv +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #else #include #include @@ -152,7 +154,7 @@ enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags) { int i; - for (i = 0; i < sizeof(env_flags_varaccess_mask); i++) + for (i = 0; i < ARRAY_SIZE(env_flags_varaccess_mask); i++) if (env_flags_varaccess_mask[i] == (binflags & ENV_FLAGS_VARACCESS_BIN_MASK)) return (enum env_flags_varaccess)i; @@ -373,21 +375,21 @@ int env_flags_validate_varaccess(const char *name, int check_mask) /* * Validate the parameters to "env set" directly */ -int env_flags_validate_env_set_params(int argc, char * const argv[]) +int env_flags_validate_env_set_params(char *name, char * const val[], int count) { - if ((argc >= 3) && argv[2] != NULL) { - enum env_flags_vartype type = env_flags_get_type(argv[1]); + if ((count >= 1) && val[0] != NULL) { + enum env_flags_vartype type = env_flags_get_type(name); /* * we don't currently check types that need more than * one argument */ - if (type != env_flags_vartype_string && argc > 3) { - printf("## Error: too many parameters for setting " - "\"%s\"\n", argv[1]); + if (type != env_flags_vartype_string && count > 1) { + printf("## Error: too many parameters for setting \"%s\"\n", + name); return -1; } - return env_flags_validate_type(argv[1], argv[2]); + return env_flags_validate_type(name, val[0]); } /* ok */ return 0; @@ -455,6 +457,7 @@ static int set_flags(const char *name, const char *value, void *priv) e.key = name; e.data = NULL; + e.callback = NULL; hsearch_r(e, FIND, &ep, &env_htab, 0); /* does the env variable actually exist? */