X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fethstat.c;h=f8bc5b540ab29cbebbe269e3e01b819a83952ca9;hp=3c03e36ab6134a20b2a42a0dcb081d7457f5be4a;hb=54619dc85fd308b21ed09a0271e5c7383c7921b9;hpb=aecd05a0a0ec4d745506a67a937de6d1d6b33db5 diff --git a/src/ethstat.c b/src/ethstat.c index 3c03e36a..f8bc5b54 100644 --- a/src/ethstat.c +++ b/src/ethstat.c @@ -24,9 +24,9 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" -#include "utils_avltree.h" +#include "utils/avltree/avltree.h" +#include "utils/common/common.h" #include "utils_complain.h" #if HAVE_SYS_IOCTL_H @@ -48,12 +48,12 @@ struct value_map_s { }; typedef struct value_map_s value_map_t; -static char **interfaces = NULL; -static size_t interfaces_num = 0; +static char **interfaces; +static size_t interfaces_num; -static c_avl_tree_t *value_map = NULL; +static c_avl_tree_t *value_map; -static _Bool collect_mapped_only = 0; +static bool collect_mapped_only; static int ethstat_add_interface(const oconfig_item_t *ci) /* {{{ */ { @@ -204,9 +204,7 @@ static int ethstat_read_interface(char *device) { fd = socket(AF_INET, SOCK_DGRAM, /* protocol = */ 0); if (fd < 0) { - char errbuf[1024]; - ERROR("ethstat plugin: Failed to open control socket: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("ethstat plugin: Failed to open control socket: %s", STRERRNO); return 1; } @@ -218,11 +216,10 @@ static int ethstat_read_interface(char *device) { status = ioctl(fd, SIOCETHTOOL, &req); if (status < 0) { - char errbuf[1024]; close(fd); ERROR("ethstat plugin: Failed to get driver information " "from %s: %s", - device, sstrerror(errno, errbuf, sizeof(errbuf))); + device, STRERRNO); return -1; } @@ -252,12 +249,10 @@ static int ethstat_read_interface(char *device) { req.ifr_data = (void *)strings; status = ioctl(fd, SIOCETHTOOL, &req); if (status < 0) { - char errbuf[1024]; close(fd); free(strings); free(stats); - ERROR("ethstat plugin: Cannot get strings from %s: %s", device, - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("ethstat plugin: Cannot get strings from %s: %s", device, STRERRNO); return -1; } @@ -266,12 +261,11 @@ static int ethstat_read_interface(char *device) { req.ifr_data = (void *)stats; status = ioctl(fd, SIOCETHTOOL, &req); if (status < 0) { - char errbuf[1024]; close(fd); free(strings); free(stats); ERROR("ethstat plugin: Reading statistics from %s failed: %s", device, - sstrerror(errno, errbuf, sizeof(errbuf))); + STRERRNO); return -1; }