From c5983592e912835fe9ed00b9d98b05580c460eae Mon Sep 17 00:00:00 2001 From: Gerlando Falauto Date: Fri, 24 Aug 2012 00:11:39 +0000 Subject: env: add check/apply logic to himport_r() Change hashtable so that a callback function will decide whether a variable can be overwritten, and possibly apply the changes. So add a new field to struct hsearch_data: o "apply" callback function to check whether a variable can be overwritten, and possibly immediately apply the changes; when NULL, no check is performed. And a new argument to himport_r(): o "do_apply": whether to call the apply callback function NOTE: This patch does not change the current behavior. Signed-off-by: Gerlando Falauto Reviewed-by: Marek Vasut --- common/env_common.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'common/env_common.c') diff --git a/common/env_common.c b/common/env_common.c index c5cefd8a50..b9865bf630 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -136,7 +136,9 @@ const uchar default_environment[] = { "\0" }; -struct hsearch_data env_htab; +struct hsearch_data env_htab = { + .apply = env_check_apply, +}; static uchar __env_get_char_spec(int index) { @@ -197,7 +199,7 @@ void set_default_env(const char *s) if (himport_r(&env_htab, (char *)default_environment, sizeof(default_environment), '\0', 0, - 0, NULL) == 0) + 0, NULL, 0 /* do_apply */) == 0) error("Environment import failed: errno = %d\n", errno); gd->flags |= GD_FLG_ENV_READY; @@ -223,7 +225,7 @@ int env_import(const char *buf, int check) } if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0, - 0, NULL)) { + 0, NULL, 0 /* do_apply */)) { gd->flags |= GD_FLG_ENV_READY; return 1; } -- cgit v1.2.3