It can happen that bucket->entries is NULL, but bsearch is annotated
such that it's second argument must be non-NULL.
Fixes: 7db0865 ("Add simple hash implementation")
Signed-off-by: Martin Wilck <martin_wilck@gmx.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/257
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
.value = NULL,
};
+ if (bucket->entries == NULL)
+ return -ENOENT;
+
entry = bsearch(&se, bucket->entries, bucket->used, sizeof(struct hash_entry),
hash_entry_cmp);
if (entry == NULL)
return 0;
}
DEFINE_TEST(test_hash_del_nonexistent,
- .description = "test deleting an element that doesn't exist",
- .expected_fail = true);
+ .description = "test deleting an element that doesn't exist");
static int test_hash_free(const struct test *t)
{