diff --git a/lib/hash.c b/lib/hash.c index ee5401b236..37f6cdcc8f 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -241,15 +241,21 @@ void hash_iterate(struct hash *hash, void (*func)(struct hash_backet *, void *), unsigned int i; struct hash_backet *hb; struct hash_backet *hbnext; + uint32_t count = 0; - for (i = 0; i < hash->size; i++) + for (i = 0; i < hash->size; i++) { for (hb = hash->index[i]; hb; hb = hbnext) { /* get pointer to next hash backet here, in case (*func) * decides to delete hb by calling hash_release */ hbnext = hb->next; (*func)(hb, arg); + count++; + } + if (count == hash->count) + return; + } } void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *), @@ -259,6 +265,7 @@ void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *), struct hash_backet *hb; struct hash_backet *hbnext; int ret = HASHWALK_CONTINUE; + uint32_t count = 0; for (i = 0; i < hash->size; i++) { for (hb = hash->index[i]; hb; hb = hbnext) { @@ -269,7 +276,10 @@ void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *), ret = (*func)(hb, arg); if (ret == HASHWALK_ABORT) return; + count++; } + if (count == hash->count) + return; } } diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 4ac7448394..65223d02bd 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2144,7 +2144,6 @@ DEFUN (vtysh_show_poll, "Thread Poll Information\n") { unsigned int i; - int idx = 0; int ret = CMD_SUCCESS; char line[100];