aboutsummaryrefslogtreecommitdiff
path: root/include/search.h
diff options
context:
space:
mode:
authorSimon Glass2020-11-05 10:33:37 -0700
committerTom Rini2020-12-04 16:09:06 -0500
commit96434a76fd254248ded19e95dc967d28e65a5edf (patch)
treef7bcdd880ec983c695273b842276bda423a72741 /include/search.h
parent4c450daf7d5d48ef075980e11052bf6bb28db4f6 (diff)
env: Allow returning errors from hdelete_r()
At present this function returns 1 on success and 0 on failure. But in the latter case it provides no indication of what went wrong. If an attempt is made to delete a non-existent variable, the caller may want to ignore this error. This happens when setting a non-existent variable to "", for example. Update the function to return 0 on success and a useful error code on failure. Add a function comment too. Make sure that env_set() does not return an error if it is deleting a variable that doesn't exist. We could update env_set() to return useful error numbers also, but that is beyond the scope of this change. Signed-off-by: Simon Glass <sjg@chromium.org> wip
Diffstat (limited to 'include/search.h')
-rw-r--r--include/search.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/search.h b/include/search.h
index e56843c26fd..d0bb44388e1 100644
--- a/include/search.h
+++ b/include/search.h
@@ -80,7 +80,16 @@ int hsearch_r(struct env_entry item, enum env_action action,
int hmatch_r(const char *match, int last_idx, struct env_entry **retval,
struct hsearch_data *htab);
-/* Search and delete entry matching "key" in internal hash table. */
+/**
+ * hdelete_r() - Search and delete entry in internal hash table
+ *
+ * @key: Name of entry to delete
+ * @htab: Hash table
+ * @flag: Flags to use (H_...)
+ * @return 0 on success, -ENOENT if not found, -EPERM if the hash table callback
+ * rejected changing the variable, -EINVAL if the hash table refused to
+ * delete the variable
+ */
int hdelete_r(const char *key, struct hsearch_data *htab, int flag);
ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag,