summaryrefslogtreecommitdiff
path: root/src/test/test-prioq.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-11-27 22:25:20 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-12-02 07:53:27 +0100
commit7a08d314f20b5d6ca44c573426a8a5c812020344 (patch)
tree871818dbd5a37c437f5dad5e6a15bcccad9c4b45 /src/test/test-prioq.c
parent25073e5012cdb4de13d815197815c33194ff7dc9 (diff)
downloadsystemd-7a08d314f20b5d6ca44c573426a8a5c812020344.tar.gz
tree-wide: make hash_ops typesafe
Diffstat (limited to 'src/test/test-prioq.c')
-rw-r--r--src/test/test-prioq.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/test/test-prioq.c b/src/test/test-prioq.c
index a93d37d460..bc5fdd15b2 100644
--- a/src/test/test-prioq.c
+++ b/src/test/test-prioq.c
@@ -48,22 +48,15 @@ struct test {
unsigned idx;
};
-static int test_compare(const void *a, const void *b) {
- const struct test *x = a, *y = b;
-
+static int test_compare(const struct test *x, const struct test *y) {
return CMP(x->value, y->value);
}
-static void test_hash(const void *a, struct siphash *state) {
- const struct test *x = a;
-
+static void test_hash(const struct test *x, struct siphash *state) {
siphash24_compress(&x->value, sizeof(x->value), state);
}
-static const struct hash_ops test_hash_ops = {
- .hash = test_hash,
- .compare = test_compare
-};
+DEFINE_PRIVATE_HASH_OPS(test_hash_ops, struct test, test_hash, test_compare);
static void test_struct(void) {
_cleanup_(prioq_freep) Prioq *q = NULL;
@@ -73,7 +66,7 @@ static void test_struct(void) {
srand(0);
- assert_se(q = prioq_new(test_compare));
+ assert_se(q = prioq_new((compare_func_t) test_compare));
assert_se(s = set_new(&test_hash_ops));
for (i = 0; i < SET_SIZE; i++) {