X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fethstat.c;h=959737a368add51263a93c1caf6fb9cab4b7c3bb;hb=8ea52acd8b66648475a886bc40546e36fe3518c6;hp=dec14f3d148962df3b1aaf41eb1f50f0a7a5f92c;hpb=7a762196fa7a4024c19ceac9b0c6918a5d8f62d5;p=collectd.git diff --git a/src/ethstat.c b/src/ethstat.c index dec14f3d..959737a3 100644 --- a/src/ethstat.c +++ b/src/ethstat.c @@ -104,14 +104,13 @@ static int ethstat_add_map (const oconfig_item_t *ci) /* {{{ */ return (ENOMEM); } - map = malloc (sizeof (*map)); + map = calloc (1, sizeof (*map)); if (map == NULL) { sfree (key); - ERROR ("ethstat plugin: malloc(3) failed."); + ERROR ("ethstat plugin: calloc failed."); return (ENOMEM); } - memset (map, 0, sizeof (*map)); sstrncpy (map->type, ci->values[1].value.string, sizeof (map->type)); if (ci->values_num == 3) @@ -120,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); @@ -273,7 +272,7 @@ static int ethstat_read_interface (char *device) close (fd); sfree (strings); sfree (stats); - ERROR("ethstat plugin: malloc(3) failed."); + ERROR("ethstat plugin: malloc failed."); return (-1); } @@ -312,9 +311,13 @@ static int ethstat_read_interface (char *device) for (i = 0; i < n_stats; i++) { - const char *stat_name; + char *stat_name; stat_name = (void *) &strings->data[i * ETH_GSTRING_LEN]; + /* Remove leading spaces in key name */ + while (isspace ((int) *stat_name)) + stat_name++; + DEBUG("ethstat plugin: device = \"%s\": %s = %"PRIu64, device, stat_name, (uint64_t) stats->data[i]); ethstat_submit_value (device,