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.
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), \
#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;
};
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);
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);