Merge remote-tracking branch 'origin/pr/1346'
[collectd.git] / src / interface.c
index 539df58..a74699e 100644 (file)
@@ -23,6 +23,7 @@
  **/
 
 #include "collectd.h"
+
 #include "common.h"
 #include "plugin.h"
 #include "configfile.h"
@@ -85,7 +86,6 @@ static const char *config_keys[] =
        "Interface",
        "IgnoreSelected",
        "ReportInactive",
-       NULL
 };
 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
 
@@ -140,7 +140,6 @@ static int interface_config (const char *key, const char *value)
 static int interface_init (void)
 {
        kstat_t *ksp_chain;
-       derive_t val;
 
        numif = 0;
 
@@ -157,7 +156,7 @@ static int interface_init (void)
                        continue;
                if (kstat_read (kc, ksp_chain, NULL) == -1)
                        continue;
-               if ((val = get_kstat_value (ksp_chain, "obytes")) == -1LL)
+               if (get_kstat_value (ksp_chain, "obytes") == -1LL)
                        continue;
                ksp[numif++] = ksp_chain;
        }
@@ -193,7 +192,6 @@ static int interface_read (void)
 {
 #if HAVE_GETIFADDRS
        struct ifaddrs *if_list;
-       struct ifaddrs *if_ptr;
 
 /* Darwin/Mac OS X and possible other *BSDs */
 #if HAVE_STRUCT_IF_DATA
@@ -223,7 +221,7 @@ static int interface_read (void)
        if (getifaddrs (&if_list) != 0)
                return (-1);
 
-       for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next)
+       for (struct ifaddrs *if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next)
        {
                if (if_ptr->ifa_addr != NULL && if_ptr->ifa_addr->sa_family == AF_LINK) {
                        if_data = (struct IFA_DATA *) if_ptr->ifa_data;
@@ -307,7 +305,6 @@ static int interface_read (void)
 /* #endif KERNEL_LINUX */
 
 #elif HAVE_LIBKSTAT
-       int i;
        derive_t rx;
        derive_t tx;
        char iname[DATA_MAX_NAME_LEN];
@@ -315,7 +312,7 @@ static int interface_read (void)
        if (kc == NULL)
                return (-1);
 
-       for (i = 0; i < numif; i++)
+       for (int i = 0; i < numif; i++)
        {
                if (kstat_read (kc, ksp[i], NULL) == -1)
                        continue;
@@ -359,11 +356,11 @@ static int interface_read (void)
 
 #elif defined(HAVE_LIBSTATGRAB)
        sg_network_io_stats *ios;
-       int i, num;
+       int num;
 
        ios = sg_get_network_io_stats (&num);
 
-       for (i = 0; i < num; i++) {
+       for (int i = 0; i < num; i++) {
                if (!report_inactive && ios[i].rx == 0 && ios[i].tx == 0)
                        continue;
                if_submit (ios[i].interface_name, "if_octets", ios[i].rx, ios[i].tx);
@@ -372,7 +369,7 @@ static int interface_read (void)
 
 #elif defined(HAVE_PERFSTAT)
        perfstat_id_t id;
-       int i, ifs;
+       int ifs;
 
        if ((nif =  perfstat_netinterface(NULL, NULL, sizeof(perfstat_netinterface_t), 0)) < 0)
        {
@@ -398,7 +395,7 @@ static int interface_read (void)
                return (-1);
        }
 
-       for (i = 0; i < ifs; i++)
+       for (int i = 0; i < ifs; i++)
        {
                if (!report_inactive && ifstat[i].ipackets == 0 && ifstat[i].opackets == 0)
                        continue;
@@ -422,12 +419,3 @@ void module_register (void)
        plugin_register_read ("interface", interface_read);
 } /* void module_register */
 
-/*
- * Local variables:
- *  c-file-style: "linux"
- *  indent-tabs-mode: t
- *  c-indent-level: 4
- *  c-basic-offset: 4
- *  tab-width: 4
- * End:
- */