summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-12-11 22:16:21 -0600
committerTom Rini <trini@ti.com>2012-12-13 11:46:55 -0700
commit7afcf3a55b5f484b3d3442053fae8186a3fb92d7 (patch)
tree1aa2c5143a1bbef6570b03652107a09832a2f2ad /include
parent3d3b52f2586a8bf1c53496547062594fd4386454 (diff)
downloadblackbird-obmc-uboot-7afcf3a55b5f484b3d3442053fae8186a3fb92d7.tar.gz
blackbird-obmc-uboot-7afcf3a55b5f484b3d3442053fae8186a3fb92d7.zip
env: Refactor apply into change_ok
Move the read of the old value to inside the check function. In some cases it can be avoided all together and at the least the code is only called from one place. Also name the function and the callback to more clearly describe what it does. Pass the ENTRY instead of just the name for direct access to the whole data structure. Pass an enum to the callback that specifies the operation being approved. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'include')
-rw-r--r--include/environment.h7
-rw-r--r--include/search.h13
2 files changed, 12 insertions, 8 deletions
diff --git a/include/environment.h b/include/environment.h
index e8ab7033bf..4b19f32be4 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -188,13 +188,12 @@ int set_default_vars(int nvars, char * const vars[]);
int env_import(const char *buf, int check);
/*
- * Check if variable "name" can be changed from oldval to newval,
- * and if so, apply the changes (e.g. baudrate).
+ * Check if variable "item" can be changed to newval
* When (flag & H_FORCE) is set, it does not print out any error
* message and forces overwriting of write-once variables.
*/
-int env_check_apply(const char *name, const char *oldval,
- const char *newval, int flag);
+int env_change_ok(const ENTRY *item, const char *newval, enum env_op op,
+ int flag);
#endif /* DO_DEPS_ONLY */
diff --git a/include/search.h b/include/search.h
index f5165b0a98..fa00ea1b35 100644
--- a/include/search.h
+++ b/include/search.h
@@ -32,6 +32,12 @@
#define __set_errno(val) do { errno = val; } while (0)
+enum env_op {
+ env_op_create,
+ env_op_delete,
+ env_op_overwrite,
+};
+
/* Action which shall be performed in the call the hsearch. */
typedef enum {
FIND,
@@ -59,14 +65,13 @@ struct hsearch_data {
unsigned int filled;
/*
* Callback function which will check whether the given change for variable
- * "name" from "oldval" to "newval" may be applied or not, and possibly apply
- * such change.
+ * "item" to "newval" may be applied or not, and possibly apply such change.
* When (flag & H_FORCE) is set, it shall not print out any error message and
* shall force overwriting of write-once variables.
.* Must return 0 for approval, 1 for denial.
*/
- int (*apply)(const char *name, const char *oldval,
- const char *newval, int flag);
+ int (*change_ok)(const ENTRY *__item, const char *newval, enum env_op,
+ int flag);
};
/* Create a new hashing table which will at most contain NEL elements. */
OpenPOWER on IntegriCloud