Commit 23e46034 authored by Rusty Russell's avatar Rusty Russell

htable: fix type of cmpfn in htable_type

It in fact takes an object and a key to compare, not two keys.

The test case had the key as first element of the object, so it worked,
but ccanlint lost track of module dependencies due to this bug, and thus
would build submodules multiple times.
parent 6156d1ab
......@@ -63,7 +63,7 @@ static inline type *htable_##name##_get(const struct htable_##name *ht, \
const HTABLE_KTYPE(keyof) k) \
{ \
/* Typecheck for cmpfn */ \
(void)sizeof(cmpfn(keyof((const type *)NULL), \
(void)sizeof(cmpfn((const type *)NULL, \
keyof((const type *)NULL))); \
return (type *)htable_get((const struct htable *)ht, \
hashfn(k), \
......
......@@ -7,6 +7,8 @@
#define NUM_VALS (1 << HTABLE_BASE_BITS)
struct obj {
/* Makes sure we don't try to treat and obj as a key or vice versa */
unsigned char unused;
unsigned int key;
};
......@@ -25,9 +27,9 @@ static size_t objhash(const unsigned int *key)
return h;
}
static bool cmp(const unsigned int *key1, const unsigned int *key2)
static bool cmp(const struct obj *obj, const unsigned int *key)
{
return *key1 == *key2;
return obj->key == *key;
}
HTABLE_DEFINE_TYPE(struct obj, objkey, objhash, cmp, obj);
......
......@@ -33,9 +33,9 @@ static const char *manifest_name(const struct manifest *m)
return m->dir;
}
static bool dir_cmp(const char *dir1, const char *dir2)
static bool dir_cmp(const struct manifest *m, const char *dir)
{
return strcmp(dir1, dir2) == 0;
return strcmp(m->dir, dir) == 0;
}
HTABLE_DEFINE_TYPE(struct manifest, manifest_name, dir_hash, dir_cmp, manifest);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment