summaryrefslogtreecommitdiff
path: root/lib/hashtable.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-08-01 09:47:09 -0600
committerTom Rini <trini@konsulko.com>2019-08-11 16:43:41 -0400
commit3f0d6807459bb22431e5bc19e597c1786b3d1ce6 (patch)
tree4d24e8d74ccea7c9577566d45d94635518a1195a /lib/hashtable.c
parentd3716dd64bb8bb4c4ba2d19bac164d24ada72a68 (diff)
downloadu-boot-3f0d6807459bb22431e5bc19e597c1786b3d1ce6.tar.gz
u-boot-3f0d6807459bb22431e5bc19e597c1786b3d1ce6.tar.bz2
u-boot-3f0d6807459bb22431e5bc19e597c1786b3d1ce6.zip
env: Drop the ACTION typedef
Avoid using a typedef here which is unnecessary. Add an 'env_' prefix to both the enum and its members to make it clear that these are related to the environment. Add an ENV prefix to these two flags so that it is clear what they relate to. Also move them to env.h since they are part of the public API. Use an enum rather than a #define to tie them together. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/hashtable.c')
-rw-r--r--lib/hashtable.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 1093d8adaa..2caab0a4c6 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -194,7 +194,7 @@ void hdestroy_r(struct hsearch_data *htab)
* data any more.
* - The standard implementation does not provide a way to update an
* existing entry. This version will create a new entry or update an
- * existing one when both "action == ENTER" and "item.data != NULL".
+ * existing one when both "action == ENV_ENTER" and "item.data != NULL".
* - Instead of returning 1 on success, we return the index into the
* internal hash table, which is also guaranteed to be positive.
* This allows us direct access to the found hash table slot for
@@ -223,17 +223,17 @@ int hmatch_r(const char *match, int last_idx, struct env_entry **retval,
/*
* Compare an existing entry with the desired key, and overwrite if the action
- * is ENTER. This is simply a helper function for hsearch_r().
+ * is ENV_ENTER. This is simply a helper function for hsearch_r().
*/
static inline int _compare_and_overwrite_entry(struct env_entry item,
- ACTION action, struct env_entry **retval,
+ enum env_action action, struct env_entry **retval,
struct hsearch_data *htab, int flag, unsigned int hval,
unsigned int idx)
{
if (htab->table[idx].used == hval
&& strcmp(item.key, htab->table[idx].entry.key) == 0) {
/* Overwrite existing value? */
- if ((action == ENTER) && (item.data != NULL)) {
+ if (action == ENV_ENTER && item.data) {
/* check for permission */
if (htab->change_ok != NULL && htab->change_ok(
&htab->table[idx].entry, item.data,
@@ -272,8 +272,8 @@ static inline int _compare_and_overwrite_entry(struct env_entry item,
return -1;
}
-int hsearch_r(struct env_entry item, ACTION action, struct env_entry **retval,
- struct hsearch_data *htab, int flag)
+int hsearch_r(struct env_entry item, enum env_action action,
+ struct env_entry **retval, struct hsearch_data *htab, int flag)
{
unsigned int hval;
unsigned int count;
@@ -354,7 +354,7 @@ int hsearch_r(struct env_entry item, ACTION action, struct env_entry **retval,
}
/* An empty bucket has been found. */
- if (action == ENTER) {
+ if (action == ENV_ENTER) {
/*
* If table is full and another entry should be
* entered return with error.
@@ -456,7 +456,7 @@ int hdelete_r(const char *key, struct hsearch_data *htab, int flag)
e.key = (char *)key;
- idx = hsearch_r(e, FIND, &ep, htab, 0);
+ idx = hsearch_r(e, ENV_FIND, &ep, htab, 0);
if (idx == 0) {
__set_errno(ESRCH);
return 0; /* not found */
@@ -931,7 +931,7 @@ int himport_r(struct hsearch_data *htab,
e.key = name;
e.data = value;
- hsearch_r(e, ENTER, &rv, htab, flag);
+ hsearch_r(e, ENV_ENTER, &rv, htab, flag);
if (rv == NULL)
printf("himport_r: can't insert \"%s=%s\" into hash table\n",
name, value);