X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Finterface.c;h=78a0d694fe18efdd0a5ac4640d157d745062abaf;hb=307c875e5a78a2729fbbe1a588d232e9a129d75a;hp=b8cc48da2a5b7ca7678160e8ae8e9fa7ff8bafa8;hpb=79963d13c1884d1d92667cc502ad20758b084a12;p=collectd.git diff --git a/src/interface.c b/src/interface.c index b8cc48da..78a0d694 100644 --- a/src/interface.c +++ b/src/interface.c @@ -120,10 +120,10 @@ static int interface_config(const char *key, const char *value) { "Solaris."); #endif /* HAVE_LIBKSTAT */ } else { - return (-1); + return -1; } - return (0); + return 0; } #if HAVE_LIBKSTAT @@ -133,7 +133,7 @@ static int interface_init(void) { numif = 0; if (kc == NULL) - return (-1); + return -1; for (numif = 0, ksp_chain = kc->kc_chain; (numif < MAX_NUMIF) && (ksp_chain != NULL); @@ -149,24 +149,22 @@ static int interface_init(void) { ksp[numif++] = ksp_chain; } - return (0); + return 0; } /* int interface_init */ #endif /* HAVE_LIBKSTAT */ static void if_submit(const char *dev, const char *type, derive_t rx, derive_t tx) { - value_t values[2]; value_list_t vl = VALUE_LIST_INIT; + value_t values[] = { + {.derive = rx}, {.derive = tx}, + }; if (ignorelist_match(ignorelist, dev) != 0) return; - values[0].derive = rx; - values[1].derive = tx; - vl.values = values; - vl.values_len = 2; - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); + vl.values_len = STATIC_ARRAY_SIZE(values); sstrncpy(vl.plugin, "interface", sizeof(vl.plugin)); sstrncpy(vl.plugin_instance, dev, sizeof(vl.plugin_instance)); sstrncpy(vl.type, type, sizeof(vl.type)); @@ -204,7 +202,7 @@ static int interface_read(void) { struct IFA_DATA *if_data; if (getifaddrs(&if_list) != 0) - return (-1); + return -1; for (struct ifaddrs *if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next) { @@ -241,7 +239,7 @@ static int interface_read(void) { char errbuf[1024]; WARNING("interface plugin: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf))); - return (-1); + return -1; } while (fgets(buffer, 1024, fh) != NULL) { @@ -291,7 +289,7 @@ static int interface_read(void) { char iname[DATA_MAX_NAME_LEN]; if (kc == NULL) - return (-1); + return -1; for (int i = 0; i < numif; i++) { if (kstat_read(kc, ksp[i], NULL) == -1) @@ -357,7 +355,7 @@ static int interface_read(void) { char errbuf[1024]; WARNING("interface plugin: perfstat_netinterface: %s", sstrerror(errno, errbuf, sizeof(errbuf))); - return (-1); + return -1; } if (pnif != nif || ifstat == NULL) { @@ -372,7 +370,7 @@ static int interface_read(void) { char errbuf[1024]; WARNING("interface plugin: perfstat_netinterface (interfaces=%d): %s", nif, sstrerror(errno, errbuf, sizeof(errbuf))); - return (-1); + return -1; } for (int i = 0; i < ifs; i++) { @@ -387,7 +385,7 @@ static int interface_read(void) { } #endif /* HAVE_PERFSTAT */ - return (0); + return 0; } /* int interface_read */ void module_register(void) {