[U-Boot] [RFC, PATCH v4 09/16] hashtable: extend hdelete_ext for autosave

AKASHI Takahiro takahiro.akashi at linaro.org
Wed Jul 17 08:25:18 UTC 2019


With this patch, an extended interface of hdelete_ext() will return
variable's attribute. The feature will be used in a successive patch
to determine if the context should be 'autosaved' or not even in case
of deletion.

Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
 include/search.h | 2 +-
 lib/hashtable.c  | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/search.h b/include/search.h
index ab0d7ccb5f8c..cf145fa79f8b 100644
--- a/include/search.h
+++ b/include/search.h
@@ -94,7 +94,7 @@ extern int hmatch_ext(const char *__match, int __last_idx, ENTRY ** __retval,
 extern int hdelete_r(const char *__key, struct hsearch_data *__htab,
 		     int __flag);
 extern int hdelete_ext(const char *__key, struct hsearch_data *__htab,
-		       unsigned int ctx, int __flag);
+		       unsigned int ctx, uint32_t *flags, int __flag);
 
 extern ssize_t hexport_r(struct hsearch_data *__htab,
 		     const char __sep, int __flag, char **__resp, size_t __size,
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 3fe1d38c827e..4a2541ecf59d 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -485,7 +485,7 @@ static void _hdelete(const char *key, struct hsearch_data *htab, ENTRY *ep,
 }
 
 int hdelete_ext(const char *key, struct hsearch_data *htab, unsigned int ctx,
-		int flag)
+		uint32_t *flags, int flag)
 {
 	ENTRY e, *ep;
 	int idx;
@@ -519,6 +519,8 @@ int hdelete_ext(const char *key, struct hsearch_data *htab, unsigned int ctx,
 		return 0;
 	}
 
+	if (flags)
+		*flags = ep->flags;
 	_hdelete(key, htab, ep, idx);
 
 	return 1;
@@ -526,7 +528,7 @@ int hdelete_ext(const char *key, struct hsearch_data *htab, unsigned int ctx,
 
 int hdelete_r(const char *key, struct hsearch_data *htab, int flag)
 {
-	return hdelete_ext(key, htab, 0, flag);
+	return hdelete_ext(key, htab, 0, NULL, flag);
 }
 
 #if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV))
@@ -985,7 +987,7 @@ int himport_ext(struct hsearch_data *htab, unsigned int ctx,
 			if (!drop_var_from_set(name, nvars, localvars))
 				continue;
 
-			if (hdelete_ext(name, htab, ctx, flag) == 0)
+			if (hdelete_ext(name, htab, ctx, NULL, flag) == 0)
 				debug("DELETE ERROR ##############################\n");
 
 			continue;
-- 
2.21.0



More information about the U-Boot mailing list