]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: make hash collision test collide harder
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 6 Oct 2022 13:27:08 +0000 (15:27 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Thu, 6 Oct 2022 13:28:26 +0000 (15:28 +0200)
The issue fixed in the previous commit now correctly triggers a failure:
("assertion (list_add(&head, &itm[j]) == &itm[j]) failed")

Turns out the "shitty" hash function was not shitty enough.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
tests/lib/test_typelist.h

index e3579c67a24d92081c0d269459fcfa0279f06085..feb42909a8cc8705f694c66e991fe3a7e3b6c407 100644 (file)
@@ -74,7 +74,7 @@ static uint32_t list_hash(const struct item *a)
 {
 #ifdef SHITTY_HASH
        /* crappy hash to get some hash collisions */
-       return a->val ^ (a->val << 29) ^ 0x55AA0000U;
+       return (a->val & 0xFF) ^ (a->val << 29) ^ 0x55AA0000U;
 #else
        return jhash_1word(a->val, 0xdeadbeef);
 #endif