From d707abbb2ff707dd34aa77c9028f23f2266f8d5f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 15 Jun 2010 19:40:44 +0930 Subject: [PATCH] typesafe_cb: fix fallout from API changes. --- ccan/asearch/asearch.h | 4 ++-- ccan/asort/asort.h | 2 +- ccan/asort/test/run-strings.c | 22 ---------------------- ccan/hashtable/hashtable.h | 4 ++-- ccan/talloc/talloc.h | 2 +- 5 files changed, 6 insertions(+), 28 deletions(-) delete mode 100644 ccan/asort/test/run-strings.c diff --git a/ccan/asearch/asearch.h b/ccan/asearch/asearch.h index 8e317b47..84625d98 100644 --- a/ccan/asearch/asearch.h +++ b/ccan/asearch/asearch.h @@ -3,7 +3,7 @@ #include #include -/* +/** * asearch - search an array of elements * @key: pointer to item being searched for * @base: pointer to data to sort @@ -24,7 +24,7 @@ #define asearch(key, base, num, cmp) \ ((__typeof__(*(base))*)(bsearch((key), (base), (num), sizeof(*(base)), \ cast_if_type(int (*)(const void *, const void *), \ - (cmp), \ + (cmp), &*(cmp), \ int (*)(const __typeof__(*(key)) *, \ const __typeof__(*(base)) *))))) #else diff --git a/ccan/asort/asort.h b/ccan/asort/asort.h index ffef1f6f..731f9bde 100644 --- a/ccan/asort/asort.h +++ b/ccan/asort/asort.h @@ -19,7 +19,7 @@ #define asort(base, num, cmp, ctx) \ _asort((base), (num), sizeof(*(base)), \ cast_if_type(int (*)(const void *, const void *, const void *), \ - (cmp), \ + (cmp), &*(cmp), \ int (*)(const __typeof__(*(base)) *, \ const __typeof__(*(base)) *, \ __typeof__(ctx))), (ctx)) diff --git a/ccan/asort/test/run-strings.c b/ccan/asort/test/run-strings.c deleted file mode 100644 index 3ec45384..00000000 --- a/ccan/asort/test/run-strings.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include -#include - -static int cmp(const int *key, const char *const *elem) -{ - return *key - atoi(*elem); -} - -int main(void) -{ - const char *args[] = { "1", "4", "7", "9" }; - int key = 7; - const char **p; - - plan_tests(1); - p = asearch(&key, args, ARRAY_SIZE(args), cmp); - ok1(p == &args[2]); - - return exit_status(); -} diff --git a/ccan/hashtable/hashtable.h b/ccan/hashtable/hashtable.h index 7aa27fb3..cd878952 100644 --- a/ccan/hashtable/hashtable.h +++ b/ccan/hashtable/hashtable.h @@ -75,14 +75,14 @@ bool hashtable_del(struct hashtable *ht, unsigned long hash, const void *p); _hashtable_traverse(ht, cast_if_type(bool (*)(void *, void *), \ cast_if_any(bool (*)(void *, \ void *), \ - (cb), (cb), \ + (cb), &*(cb), \ bool (*)(const type *, \ const typeof(*cbarg) *), \ bool (*)(type *, \ const typeof(*cbarg) *), \ bool (*)(const type *, \ typeof(*cbarg) *)), \ - (cb), \ + &*(cb), \ bool (*)(type *, typeof(*cbarg) *)), \ (cbarg)) diff --git a/ccan/talloc/talloc.h b/ccan/talloc/talloc.h index 54a70205..e4f15aee 100644 --- a/ccan/talloc/talloc.h +++ b/ccan/talloc/talloc.h @@ -196,7 +196,7 @@ int talloc_free(const void *ptr); * talloc, talloc_free */ #define talloc_set_destructor(ptr, function) \ - _talloc_set_destructor((ptr), typesafe_cb(int, (function), (ptr))) + _talloc_set_destructor((ptr), typesafe_cb_def(int, (function), (ptr))) /** * talloc_zero - allocate zeroed dynamic memory for a type -- 2.39.2