X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fethstat.c;h=39af140708389406fd8a992f293a3ca0900b2658;hb=6fd0d2574fc386c2724c8307d33b12529b30048b;hp=e10021c581155e4fe3887c8ecaaf4fbf4bbeee94;hpb=38909dcf1dcb596c5f525c6bb25cf89c046013b5;p=collectd.git diff --git a/src/ethstat.c b/src/ethstat.c index e10021c5..39af1407 100644 --- a/src/ethstat.c +++ b/src/ethstat.c @@ -23,6 +23,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" #include "configfile.h" @@ -119,7 +120,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); @@ -216,8 +217,6 @@ static void ethstat_submit_value (const char *device, static int ethstat_read_interface (char *device) { int fd; - struct ifreq req; - struct ethtool_drvinfo drvinfo; struct ethtool_gstrings *strings; struct ethtool_stats *stats; size_t n_stats; @@ -226,9 +225,6 @@ static int ethstat_read_interface (char *device) size_t i; int status; - memset (&req, 0, sizeof (req)); - sstrncpy(req.ifr_name, device, sizeof (req.ifr_name)); - fd = socket(AF_INET, SOCK_DGRAM, /* protocol = */ 0); if (fd < 0) { @@ -238,9 +234,16 @@ static int ethstat_read_interface (char *device) return 1; } - memset (&drvinfo, 0, sizeof (drvinfo)); - drvinfo.cmd = ETHTOOL_GDRVINFO; - req.ifr_data = (void *) &drvinfo; + struct ethtool_drvinfo drvinfo = { + .cmd = ETHTOOL_GDRVINFO + }; + + struct ifreq req = { + .ifr_data = (void *) &drvinfo + }; + + sstrncpy(req.ifr_name, device, sizeof (req.ifr_name)); + status = ioctl (fd, SIOCETHTOOL, &req); if (status < 0) {