* [U-Boot] env: fix env var autocompletion
@ 2011-04-05 1:17 Kim Phillips
2011-04-05 1:53 ` Mike Frysinger
0 siblings, 1 reply; 6+ messages in thread
From: Kim Phillips @ 2011-04-05 1:17 UTC (permalink / raw)
To: u-boot
commit 560d424b6d7cd4205b062ad95f1b104bd4f8bcc3 "env: re-add
support for auto-completion" fell short of its description -
the 'used' logic in hmatch_r was reversed - '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.
typing 'printenv tft' and hitting 'tab' now displays valid
choices for variable names.
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
lib/hashtable.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/hashtable.c b/lib/hashtable.c
index fcdb53c..92eaa38 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -209,7 +209,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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] env: fix env var autocompletion
2011-04-05 1:17 [U-Boot] env: fix env var autocompletion Kim Phillips
@ 2011-04-05 1:53 ` Mike Frysinger
2011-04-05 4:44 ` Peter Barada
0 siblings, 1 reply; 6+ messages in thread
From: Mike Frysinger @ 2011-04-05 1:53 UTC (permalink / raw)
To: u-boot
On Monday, April 04, 2011 21:17:45 Kim Phillips wrote:
> commit 560d424b6d7cd4205b062ad95f1b104bd4f8bcc3 "env: re-add
> support for auto-completion" fell short of its description -
> the 'used' logic in hmatch_r was reversed - '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.
i dont think my commit is wrong. i think the bug you describe was actually
added in c81c1222427f268d29ba999c82e2477c428e7bab.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110404/ba3e4062/attachment.pgp
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] env: fix env var autocompletion
2011-04-05 1:53 ` Mike Frysinger
@ 2011-04-05 4:44 ` Peter Barada
2011-04-05 17:14 ` [U-Boot] [PATCH v2] lib/hashtable: " Kim Phillips
0 siblings, 1 reply; 6+ messages in thread
From: Peter Barada @ 2011-04-05 4:44 UTC (permalink / raw)
To: u-boot
> On Monday, April 04, 2011 21:17:45 Kim Phillips wrote:
>> commit 560d424b6d7cd4205b062ad95f1b104bd4f8bcc3 "env: re-add
>> support for auto-completion" fell short of its description -
>> the 'used' logic in hmatch_r was reversed - '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.
> i dont think my commit is wrong. i think the bug you describe was actually
> added in c81c1222427f268d29ba999c82e2477c428e7bab.
You're right; I accidentally inverted the condition in my patch; it orignally was:
if (!htab->table[idx].used)
continue;
Since a deleted entry is now -1 (and an unused entry is zero), the condition should have been:
if (htab->table[idx].used <= 0)
continue;
not:
if (htab->table[idx].used > 0)
continue;
> -mike
--
Peter Barada
peter.barada at logicpd.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2] lib/hashtable: fix env var autocompletion
2011-04-05 4:44 ` Peter Barada
@ 2011-04-05 17:14 ` Kim Phillips
2011-04-15 7:57 ` Mike Frysinger
2011-04-27 22:55 ` Wolfgang Denk
0 siblings, 2 replies; 6+ messages in thread
From: Kim Phillips @ 2011-04-05 17:14 UTC (permalink / raw)
To: u-boot
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@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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2] lib/hashtable: fix env var autocompletion
2011-04-05 17:14 ` [U-Boot] [PATCH v2] lib/hashtable: " Kim Phillips
@ 2011-04-15 7:57 ` Mike Frysinger
2011-04-27 22:55 ` Wolfgang Denk
1 sibling, 0 replies; 6+ messages in thread
From: Mike Frysinger @ 2011-04-15 7:57 UTC (permalink / raw)
To: u-boot
On Tuesday, April 05, 2011 13:14:50 Kim Phillips wrote:
> 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.
blah, this started to annoy me quite a bit. and your patch wfm.
Tested-by: Mike Frysinger <vapier@gentoo.org>
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110415/67e4ec72/attachment.pgp
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2] lib/hashtable: fix env var autocompletion
2011-04-05 17:14 ` [U-Boot] [PATCH v2] lib/hashtable: " Kim Phillips
2011-04-15 7:57 ` Mike Frysinger
@ 2011-04-27 22:55 ` Wolfgang Denk
1 sibling, 0 replies; 6+ messages in thread
From: Wolfgang Denk @ 2011-04-27 22:55 UTC (permalink / raw)
To: u-boot
Dear Kim Phillips,
In message <20110405121450.099cb324.kim.phillips@freescale.com> you wrote:
> 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@freescale.com>
> ---
> v2: fix commit message to point to correct source of failure
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Beware of the Turing Tar-pit in which everything is possible but
nothing of interest is easy.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-04-27 22:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-05 1:17 [U-Boot] env: fix env var autocompletion Kim Phillips
2011-04-05 1:53 ` Mike Frysinger
2011-04-05 4:44 ` Peter Barada
2011-04-05 17:14 ` [U-Boot] [PATCH v2] lib/hashtable: " Kim Phillips
2011-04-15 7:57 ` Mike Frysinger
2011-04-27 22:55 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox