From: Ruben Kerkhof Date: Sun, 24 Jul 2016 16:43:38 +0000 (+0200) Subject: treewide: fix invocation of c_avl_create X-Git-Tag: collectd-5.6.0~156 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=1a0d2707d5fb73cd778831acf8af4980225b0bbc;p=collectd.git treewide: fix invocation of c_avl_create Fixes the following warning on Solaris: |c_avl_tree_t *c_avl_create (int (*compare) (const void *, const void *)); | ^ line 54, utils_avltree.h | included in line 34, utils_vl_lookup.c | | obj->by_type_tree = c_avl_create ((void *) strcmp); | ^ line 567, utils_vl_lookup.c E_ARG_INCOMPATIBLE_WITH_ARG_L, argument #1 is incompatible with prototype: prototype: pointer to function(pointer to const void, pointer to const void) returning int : "src/daemon/utils_avltree.h", line 54 argument : pointer to void I'll look into writing a generic function to compare avl keys so we don't need to do all the casting. --- diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c index 3a2e2878..9258b885 100644 --- a/src/daemon/plugin.c +++ b/src/daemon/plugin.c @@ -976,7 +976,7 @@ static _Bool plugin_is_loaded (char const *name) int status; if (plugins_loaded == NULL) - plugins_loaded = c_avl_create ((void *) strcasecmp); + plugins_loaded = c_avl_create ((int (*) (const void *, const void *)) strcasecmp); assert (plugins_loaded != NULL); status = c_avl_get (plugins_loaded, name, /* ret_value = */ NULL); diff --git a/src/ethstat.c b/src/ethstat.c index e10021c5..959737a3 100644 --- a/src/ethstat.c +++ b/src/ethstat.c @@ -119,7 +119,7 @@ static int ethstat_add_map (const oconfig_item_t *ci) /* {{{ */ if (value_map == NULL) { - value_map = c_avl_create ((void *) strcmp); + value_map = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (value_map == NULL) { sfree (map); diff --git a/src/gmond.c b/src/gmond.c index 70436d72..728162ec 100644 --- a/src/gmond.c +++ b/src/gmond.c @@ -1107,7 +1107,7 @@ static int gmond_init (void) /* {{{ */ (mc_receive_port != NULL) ? mc_receive_port : MC_RECEIVE_PORT_DEFAULT, /* listen = */ 0); - staging_tree = c_avl_create ((void *) strcmp); + staging_tree = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (staging_tree == NULL) { ERROR ("gmond plugin: c_avl_create failed."); diff --git a/src/statsd.c b/src/statsd.c index 57cdbc55..a0c6e4f3 100644 --- a/src/statsd.c +++ b/src/statsd.c @@ -355,7 +355,7 @@ static int statsd_handle_set (char const *name, /* {{{ */ /* Make sure metric->set exists. */ if (metric->set == NULL) - metric->set = c_avl_create ((void *) strcmp); + metric->set = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (metric->set == NULL) { @@ -709,7 +709,7 @@ static int statsd_init (void) /* {{{ */ { pthread_mutex_lock (&metrics_lock); if (metrics_tree == NULL) - metrics_tree = c_avl_create ((void *) strcmp); + metrics_tree = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (!network_thread_running) { diff --git a/src/threshold.c b/src/threshold.c index d9d7f9e2..77ba3f32 100644 --- a/src/threshold.c +++ b/src/threshold.c @@ -874,7 +874,7 @@ static int ut_config (oconfig_item_t *ci) if (threshold_tree == NULL) { - threshold_tree = c_avl_create ((void *) strcmp); + threshold_tree = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (threshold_tree == NULL) { ERROR ("ut_config: c_avl_create failed."); diff --git a/src/utils_fbhash.c b/src/utils_fbhash.c index 41f640af..d1a580cd 100644 --- a/src/utils_fbhash.c +++ b/src/utils_fbhash.c @@ -91,7 +91,7 @@ static int fbh_read_file (fbhash_t *h) /* {{{ */ return (-1); } - tree = c_avl_create ((void *) strcmp); + tree = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (tree == NULL) { fclose (fh); diff --git a/src/utils_vl_lookup.c b/src/utils_vl_lookup.c index 8a2e5671..6081c90e 100644 --- a/src/utils_vl_lookup.c +++ b/src/utils_vl_lookup.c @@ -381,7 +381,7 @@ static by_type_entry_t *lu_search_by_type (lookup_t *obj, /* {{{ */ } by_type->wildcard_plugin_list = NULL; - by_type->by_plugin_tree = c_avl_create ((void *) strcmp); + by_type->by_plugin_tree = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (by_type->by_plugin_tree == NULL) { ERROR ("utils_vl_lookup: c_avl_create failed."); @@ -564,7 +564,7 @@ lookup_t *lookup_create (lookup_class_callback_t cb_user_class, /* {{{ */ return (NULL); } - obj->by_type_tree = c_avl_create ((void *) strcmp); + obj->by_type_tree = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (obj->by_type_tree == NULL) { ERROR ("utils_vl_lookup: c_avl_create failed."); diff --git a/src/zone.c b/src/zone.c index 40c4d2ee..87c65172 100644 --- a/src/zone.c +++ b/src/zone.c @@ -48,11 +48,11 @@ typedef struct zone_stats { } zone_stats_t; static int -zone_compare(const zoneid_t *a, const zoneid_t *b) +zone_compare(const void *a, const void *b) { - if (*a == *b) + if (*(const zoneid_t *)a == *(const zoneid_t *)b) return(0); - if (*a < *b) + if (*(const zoneid_t *)a < *(const zoneid_t *)b) return(-1); return(1); } @@ -152,7 +152,7 @@ zone_scandir(DIR *procdir) c_avl_tree_t *tree; zone_stats_t *stats; - if (!(tree=c_avl_create((void *) zone_compare))) { + if (!(tree=c_avl_create(zone_compare))) { WARNING("zone plugin: Failed to create tree"); return(NULL); }