diff --git a/api/api.c b/api/api.c
index a0fc62ca9e513693790d1b7f687f21151d9be401..cd7487fde26aafa22cd81b8a0c37cce5d08d7d12 100644
--- a/api/api.c
+++ b/api/api.c
@@ -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 995b6b37af680c17a107001c17895cd830ae3f1d..8e8572235cb70250b52b1235679420f93bb86b39 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 4bbcf74967309287237fc44c154b104fa660a680..4b91e7db1bc65548543d3faa985db0024fe97f51 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 d539da93aaaaca98a9c9760a8a588e047c20a82b..d5469ce3c271e224a7fe9cdf03943dc1ff33659d 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 fdbad7bf33419b51a2626a2c32182f0dba5cc7e8..93d337a1aa0ce187d571be66a6533971b15dd83e 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 c99648f80b76dc38b4bab91db954fe73fc46e41b..84fc5fd3fdf1bfcb6261b55bb4a97406ebc3b798 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 1093d8adaa6a9a8df8b495dbbeabe7b93c2fbcde..2caab0a4c6d3157d3de8d83757bacfa00e257265 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 bad276bd10aad007771e0546fdc795d5560535fe..5242c4cc3edb7fb4105ec5787065f90cdec940bc 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);