[U-Boot] [PATCH v2] lib/hashtable: fix env var autocompletion

Kim Phillips kim.phillips at freescale.com
Tue Apr 5 19:14:50 CEST 2011


commit c81c1222427f268d29ba999c82e2477c428e7bab "Fix hash
table deletion to prevent lost entries" broke environment
variable autocompletion by accidentally inverting the
condition for 'used' in hmatch_r().

'used' is 0 if the hash table entry is not used, or -1 if deleted.
This patch makes hmatch_r actually match on valid ('used') entries,
instead of skipping them and failing to match anything.

Signed-off-by: Kim Phillips <kim.phillips at freescale.com>
---
v2: fix commit message to point to correct source of failure

 lib/hashtable.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/hashtable.c b/lib/hashtable.c
index 2788a65..19d5b15 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -232,7 +232,7 @@ int hmatch_r(const char *match, int last_idx, ENTRY ** retval,
 	size_t key_len = strlen(match);
 
 	for (idx = last_idx + 1; idx < htab->size; ++idx) {
-		if (htab->table[idx].used > 0)
+		if (htab->table[idx].used <= 0)
 			continue;
 		if (!strncmp(match, htab->table[idx].entry.key, key_len)) {
 			*retval = &htab->table[idx].entry;
-- 
1.7.4.2.dirty




More information about the U-Boot mailing list