summaryrefslogtreecommitdiff
path: root/src/hwdb
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-09-18 08:58:42 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-09-19 08:05:13 +0900
commitba0a7bfb983305ac7f86db1e7bbfeb456e11bbd8 (patch)
tree27da10cab2e1d123ca198321c7d2a76cd80eb10a /src/hwdb
parent5532395be7aecae768afd96d37a30834167711a0 (diff)
downloadsystemd-ba0a7bfb983305ac7f86db1e7bbfeb456e11bbd8.tar.gz
tree-wide: use typesafe_qsort_r()
Diffstat (limited to 'src/hwdb')
-rw-r--r--src/hwdb/hwdb.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c
index 913cefaec6..d9a6d8390d 100644
--- a/src/hwdb/hwdb.c
+++ b/src/hwdb/hwdb.c
@@ -133,13 +133,9 @@ static void trie_free(struct trie *trie) {
DEFINE_TRIVIAL_CLEANUP_FUNC(struct trie*, trie_free);
-static int trie_values_cmp(const void *v1, const void *v2, void *arg) {
- const struct trie_value_entry *val1 = v1;
- const struct trie_value_entry *val2 = v2;
- struct trie *trie = arg;
-
- return strcmp(trie->strings->buf + val1->key_off,
- trie->strings->buf + val2->key_off);
+static int trie_values_cmp(const struct trie_value_entry *a, const struct trie_value_entry *b, struct trie *trie) {
+ return strcmp(trie->strings->buf + a->key_off,
+ trie->strings->buf + b->key_off);
}
static int trie_node_add_value(struct trie *trie, struct trie_node *node,
@@ -164,7 +160,7 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node,
.value_off = v,
};
- val = xbsearch_r(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie);
+ val = xbsearch_r(&search, node->values, node->values_count, sizeof(struct trie_value_entry), (__compar_d_fn_t) trie_values_cmp, trie);
if (val) {
/* At this point we have 2 identical properties on the same match-string.
* Since we process files in order, we just replace the previous value.
@@ -189,7 +185,7 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node,
node->values[node->values_count].file_priority = file_priority;
node->values[node->values_count].line_number = line_number;
node->values_count++;
- qsort_r(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie);
+ typesafe_qsort_r(node->values, node->values_count, trie_values_cmp, trie);
return 0;
}