diff options
-rw-r--r-- | api/api.c | 2 | ||||
-rw-r--r-- | cmd/nvedit.c | 8 | ||||
-rw-r--r-- | drivers/tee/sandbox.c | 6 | ||||
-rw-r--r-- | env/callback.c | 2 | ||||
-rw-r--r-- | env/flags.c | 2 | ||||
-rw-r--r-- | include/search.h | 16 | ||||
-rw-r--r-- | lib/hashtable.c | 18 | ||||
-rw-r--r-- | test/env/hashtable.c | 8 |
8 files changed, 31 insertions, 31 deletions
@@ -514,7 +514,7 @@ static int API_env_enum(va_list ap) if (s != NULL) *s = 0; search.key = var; - i = hsearch_r(search, FIND, &match, &env_htab, 0); + i = hsearch_r(search, ENV_FIND, &match, &env_htab, 0); if (i == 0) { i = API_EINVAL; goto done; diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 995b6b37af..8e8572235c 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -98,7 +98,7 @@ static int env_print(char *name, int flag) e.key = name; e.data = NULL; - hsearch_r(e, FIND, &ep, &env_htab, flag); + hsearch_r(e, ENV_FIND, &ep, &env_htab, flag); if (ep == NULL) return 0; len = printf("%s=%s\n", ep->key, ep->data); @@ -288,7 +288,7 @@ static int _do_env_set(int flag, int argc, char * const argv[], int env_flag) e.key = name; e.data = value; - hsearch_r(e, ENTER, &ep, &env_htab, env_flag); + hsearch_r(e, ENV_ENTER, &ep, &env_htab, env_flag); free(value); if (!ep) { printf("## Error inserting \"%s\" variable, errno=%d\n", @@ -668,7 +668,7 @@ char *env_get(const char *name) e.key = name; e.data = NULL; - hsearch_r(e, FIND, &ep, &env_htab, 0); + hsearch_r(e, ENV_FIND, &ep, &env_htab, 0); return ep ? ep->data : NULL; } @@ -1269,7 +1269,7 @@ static int do_env_exists(cmd_tbl_t *cmdtp, int flag, int argc, e.key = argv[1]; e.data = NULL; - hsearch_r(e, FIND, &ep, &env_htab, 0); + hsearch_r(e, ENV_FIND, &ep, &env_htab, 0); return (ep == NULL) ? 1 : 0; } diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c index 4bbcf74967..4b91e7db1b 100644 --- a/drivers/tee/sandbox.c +++ b/drivers/tee/sandbox.c @@ -174,7 +174,7 @@ static u32 ta_avb_invoke_func(struct udevice *dev, u32 func, uint num_params, e.key = name; e.data = NULL; - hsearch_r(e, FIND, &ep, &state->pstorage_htab, 0); + hsearch_r(e, ENV_FIND, &ep, &state->pstorage_htab, 0); if (!ep) return TEE_ERROR_ITEM_NOT_FOUND; @@ -198,13 +198,13 @@ static u32 ta_avb_invoke_func(struct udevice *dev, u32 func, uint num_params, e.key = name; e.data = NULL; - hsearch_r(e, FIND, &ep, &state->pstorage_htab, 0); + hsearch_r(e, ENV_FIND, &ep, &state->pstorage_htab, 0); if (ep) hdelete_r(e.key, &state->pstorage_htab, 0); e.key = name; e.data = value; - hsearch_r(e, ENTER, &ep, &state->pstorage_htab, 0); + hsearch_r(e, ENV_ENTER, &ep, &state->pstorage_htab, 0); if (!ep) return TEE_ERROR_OUT_OF_MEMORY; diff --git a/env/callback.c b/env/callback.c index d539da93aa..d5469ce3c2 100644 --- a/env/callback.c +++ b/env/callback.c @@ -98,7 +98,7 @@ static int set_callback(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); + hsearch_r(e, ENV_FIND, &ep, &env_htab, 0); /* does the env variable actually exist? */ if (ep != NULL) { diff --git a/env/flags.c b/env/flags.c index fdbad7bf33..93d337a1aa 100644 --- a/env/flags.c +++ b/env/flags.c @@ -458,7 +458,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); + hsearch_r(e, ENV_FIND, &ep, &env_htab, 0); /* does the env variable actually exist? */ if (ep != NULL) { diff --git a/include/search.h b/include/search.h index c99648f80b..84fc5fd3fd 100644 --- a/include/search.h +++ b/include/search.h @@ -19,11 +19,11 @@ #define __set_errno(val) do { errno = val; } while (0) -/* Action which shall be performed in the call to hsearch. */ -typedef enum { - FIND, - ENTER -} ACTION; +/* enum env_action: action which shall be performed in the call to hsearch */ +enum env_action { + ENV_FIND, + ENV_ENTER, +}; /** struct env_entry - An entry in the environment hashtable */ struct env_entry { @@ -64,11 +64,11 @@ extern void hdestroy_r(struct hsearch_data *__htab); /* * Search for entry matching __item.key in internal hash table. If - * ACTION is `FIND' return found entry or signal error by returning - * NULL. If ACTION is `ENTER' replace existing data (if any) with + * __action is `ENV_FIND' return found entry or signal error by returning + * NULL. If __action is `ENV_ENTER' replace existing data (if any) with * __item.data. * */ -extern int hsearch_r(struct env_entry __item, ACTION __action, +extern int hsearch_r(struct env_entry __item, enum env_action __action, struct env_entry **__retval, struct hsearch_data *__htab, int __flag); 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); diff --git a/test/env/hashtable.c b/test/env/hashtable.c index bad276bd10..5242c4cc3e 100644 --- a/test/env/hashtable.c +++ b/test/env/hashtable.c @@ -28,7 +28,7 @@ static int htab_fill(struct unit_test_state *uts, item.data = key; item.flags = 0; item.key = key; - ut_asserteq(1, hsearch_r(item, ENTER, &ritem, htab, 0)); + ut_asserteq(1, hsearch_r(item, ENV_ENTER, &ritem, htab, 0)); } return 0; @@ -48,7 +48,7 @@ static int htab_check_fill(struct unit_test_state *uts, item.flags = 0; item.data = key; item.key = key; - hsearch_r(item, FIND, &ritem, htab, 0); + hsearch_r(item, ENV_FIND, &ritem, htab, 0); ut_assert(ritem); ut_asserteq_str(key, ritem->key); ut_asserteq_str(key, ritem->data); @@ -71,10 +71,10 @@ static int htab_create_delete(struct unit_test_state *uts, item.flags = 0; item.data = key; item.key = key; - hsearch_r(item, ENTER, &ritem, htab, 0); + hsearch_r(item, ENV_ENTER, &ritem, htab, 0); ritem = NULL; - hsearch_r(item, FIND, &ritem, htab, 0); + hsearch_r(item, ENV_FIND, &ritem, htab, 0); ut_assert(ritem); ut_asserteq_str(key, ritem->key); ut_asserteq_str(key, ritem->data); |