X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnetapp.c;h=d73969646f7ca9be74c966fcd3da03d2754cc0a0;hb=89be8ccf23c003d22d112de0fe5417d747fa20a4;hp=45395ae04b0daf7c7fc9656a5c09b94388711bf9;hpb=3fae5596643f1e361eb18c3d65448f8bc02fdd80;p=collectd.git diff --git a/src/netapp.c b/src/netapp.c index 45395ae0..d7396964 100644 --- a/src/netapp.c +++ b/src/netapp.c @@ -27,6 +27,7 @@ **/ #include "collectd.h" + #include "common.h" #include "utils_ignorelist.h" @@ -893,7 +894,6 @@ static int cna_handle_wafl_data (const char *hostname, cfg_wafl_t *cfg_wafl, /* const char *plugin_inst; na_elem_t *instances; - na_elem_t *counter; na_elem_iter_t counter_iter; perf_data.timestamp = cna_child_get_cdtime (data); @@ -918,7 +918,7 @@ static int cna_handle_wafl_data (const char *hostname, cfg_wafl_t *cfg_wafl, /* /* Iterate over all counters */ counter_iter = na_child_iterator (na_elem_child (instances, "counters")); - for (counter = na_iterator_next (&counter_iter); + for (na_elem_t *counter = na_iterator_next (&counter_iter); counter != NULL; counter = na_iterator_next (&counter_iter)) { @@ -1054,7 +1054,6 @@ static int cna_handle_disk_data (const char *hostname, /* {{{ */ { cdtime_t timestamp; na_elem_t *instances; - na_elem_t *instance; na_elem_iter_t instance_iter; disk_t *worst_disk = NULL; @@ -1074,7 +1073,7 @@ static int cna_handle_disk_data (const char *hostname, /* {{{ */ /* Iterate over all children */ instance_iter = na_child_iterator (instances); - for (instance = na_iterator_next (&instance_iter); + for (na_elem_t *instance = na_iterator_next (&instance_iter); instance != NULL; instance = na_iterator_next(&instance_iter)) { @@ -1082,7 +1081,6 @@ static int cna_handle_disk_data (const char *hostname, /* {{{ */ disk_t new_data = { 0 }; na_elem_iter_t counter_iterator; - na_elem_t *counter; new_data.timestamp = timestamp; new_data.disk_busy_percent = NAN; @@ -1093,7 +1091,7 @@ static int cna_handle_disk_data (const char *hostname, /* {{{ */ /* Look for the "disk_busy" and "base_for_disk_busy" counters */ counter_iterator = na_child_iterator(na_elem_child(instance, "counters")); - for (counter = na_iterator_next(&counter_iterator); + for (na_elem_t *counter = na_iterator_next(&counter_iterator); counter != NULL; counter = na_iterator_next(&counter_iterator)) { @@ -1250,7 +1248,6 @@ static int cna_handle_volume_perf_data (const char *hostname, /* {{{ */ cdtime_t timestamp; na_elem_t *elem_instances; na_elem_iter_t iter_instances; - na_elem_t *elem_instance; timestamp = cna_child_get_cdtime (data); @@ -1264,7 +1261,7 @@ static int cna_handle_volume_perf_data (const char *hostname, /* {{{ */ } iter_instances = na_child_iterator (elem_instances); - for (elem_instance = na_iterator_next(&iter_instances); + for (na_elem_t *elem_instance = na_iterator_next(&iter_instances); elem_instance != NULL; elem_instance = na_iterator_next(&iter_instances)) { @@ -1275,7 +1272,6 @@ static int cna_handle_volume_perf_data (const char *hostname, /* {{{ */ na_elem_t *elem_counters; na_elem_iter_t iter_counters; - na_elem_t *elem_counter; perf_data.timestamp = timestamp; @@ -1293,7 +1289,7 @@ static int cna_handle_volume_perf_data (const char *hostname, /* {{{ */ continue; iter_counters = na_child_iterator (elem_counters); - for (elem_counter = na_iterator_next(&iter_counters); + for (na_elem_t *elem_counter = na_iterator_next(&iter_counters); elem_counter != NULL; elem_counter = na_iterator_next(&iter_counters)) { @@ -1418,9 +1414,7 @@ static int cna_query_volume_perf (host_config_t *host) /* {{{ */ static int cna_submit_volume_usage_data (const char *hostname, /* {{{ */ cfg_volume_usage_t *cfg_volume, int interval) { - data_volume_usage_t *v; - - for (v = cfg_volume->volumes; v != NULL; v = v->next) + for (data_volume_usage_t *v = cfg_volume->volumes; v != NULL; v = v->next) { char plugin_instance[DATA_MAX_NAME_LEN]; @@ -1541,7 +1535,7 @@ static void cna_handle_volume_snap_usage(const host_config_t *host, /* {{{ */ data_volume_usage_t *v) { uint64_t snap_used = 0, value; - na_elem_t *data, *elem_snap, *elem_snapshots; + na_elem_t *data, *elem_snapshots; na_elem_iter_t iter_snap; data = na_server_invoke_elem(host->srv, v->snap_query); @@ -1573,7 +1567,7 @@ static void cna_handle_volume_snap_usage(const host_config_t *host, /* {{{ */ } iter_snap = na_child_iterator (elem_snapshots); - for (elem_snap = na_iterator_next (&iter_snap); + for (na_elem_t *elem_snap = na_iterator_next (&iter_snap); elem_snap != NULL; elem_snap = na_iterator_next (&iter_snap)) { @@ -1688,7 +1682,6 @@ static void cna_handle_volume_sis_saved (const host_config_t *host, /* {{{ */ static int cna_handle_volume_usage_data (const host_config_t *host, /* {{{ */ cfg_volume_usage_t *cfg_volume, na_elem_t *data) { - na_elem_t *elem_volume; na_elem_t *elem_volumes; na_elem_iter_t iter_volume; @@ -1702,7 +1695,7 @@ static int cna_handle_volume_usage_data (const host_config_t *host, /* {{{ */ } iter_volume = na_child_iterator (elem_volumes); - for (elem_volume = na_iterator_next (&iter_volume); + for (na_elem_t *elem_volume = na_iterator_next (&iter_volume); elem_volume != NULL; elem_volume = na_iterator_next (&iter_volume)) { @@ -1826,7 +1819,6 @@ static int cna_query_volume_usage (host_config_t *host) /* {{{ */ static int cna_handle_quota_data (const host_config_t *host, /* {{{ */ cfg_quota_t *cfg_quota, na_elem_t *data) { - na_elem_t *elem_quota; na_elem_t *elem_quotas; na_elem_iter_t iter_quota; @@ -1840,7 +1832,7 @@ static int cna_handle_quota_data (const host_config_t *host, /* {{{ */ } iter_quota = na_child_iterator (elem_quotas); - for (elem_quota = na_iterator_next (&iter_quota); + for (na_elem_t *elem_quota = na_iterator_next (&iter_quota); elem_quota != NULL; elem_quota = na_iterator_next (&iter_quota)) { @@ -1952,7 +1944,6 @@ static int cna_query_quota (host_config_t *host) /* {{{ */ static int cna_handle_snapvault_data (const char *hostname, /* {{{ */ cfg_snapvault_t *cfg_snapvault, na_elem_t *data, cdtime_t interval) { - na_elem_t *status; na_elem_iter_t status_iter; status = na_elem_child (data, "status-list"); @@ -1962,7 +1953,7 @@ static int cna_handle_snapvault_data (const char *hostname, /* {{{ */ } status_iter = na_child_iterator (status); - for (status = na_iterator_next (&status_iter); + for (na_elem_t *status = na_iterator_next (&status_iter); status != NULL; status = na_iterator_next (&status_iter)) { @@ -2012,7 +2003,6 @@ static int cna_handle_snapvault_iter (host_config_t *host, /* {{{ */ const char *tag; uint32_t records_count; - uint32_t i; records_count = na_child_get_uint32 (data, "records", UINT32_MAX); if (records_count == UINT32_MAX) @@ -2024,7 +2014,7 @@ static int cna_handle_snapvault_iter (host_config_t *host, /* {{{ */ DEBUG ("netapp plugin: Iterating %u SV records (tag = %s)", records_count, tag); - for (i = 0; i < records_count; ++i) { + for (uint32_t i = 0; i < records_count; ++i) { na_elem_t *elem; elem = na_server_invoke (host->srv, @@ -2113,7 +2103,6 @@ static int cna_handle_system_data (const char *hostname, /* {{{ */ cfg_system_t *cfg_system, na_elem_t *data, int interval) { na_elem_t *instances; - na_elem_t *counter; na_elem_iter_t counter_iter; derive_t disk_read = 0, disk_written = 0; @@ -2145,7 +2134,7 @@ static int cna_handle_system_data (const char *hostname, /* {{{ */ } counter_iter = na_child_iterator (na_elem_child (instances, "counters")); - for (counter = na_iterator_next (&counter_iter); + for (na_elem_t *counter = na_iterator_next (&counter_iter); counter != NULL; counter = na_iterator_next (&counter_iter)) { @@ -2390,7 +2379,6 @@ static int cna_config_volume_performance (host_config_t *host, /* {{{ */ const oconfig_item_t *ci) { cfg_volume_perf_t *cfg_volume_perf; - int i; if ((host == NULL) || (ci == NULL)) return (EINVAL); @@ -2433,7 +2421,7 @@ static int cna_config_volume_performance (host_config_t *host, /* {{{ */ } cfg_volume_perf = host->cfg_volume_perf; - for (i = 0; i < ci->children_num; ++i) { + for (int i = 0; i < ci->children_num; ++i) { oconfig_item_t *item = ci->children + i; /* if (!item || !item->key || !*item->key) continue; */ @@ -2517,7 +2505,6 @@ static void cna_config_volume_usage_default (cfg_volume_usage_t *cvu, /* {{{ */ static int cna_config_quota (host_config_t *host, oconfig_item_t *ci) /* {{{ */ { cfg_quota_t *cfg_quota; - int i; if ((host == NULL) || (ci == NULL)) return (EINVAL); @@ -2533,7 +2520,7 @@ static int cna_config_quota (host_config_t *host, oconfig_item_t *ci) /* {{{ */ } cfg_quota = host->cfg_quota; - for (i = 0; i < ci->children_num; ++i) { + for (int i = 0; i < ci->children_num; ++i) { oconfig_item_t *item = ci->children + i; if (strcasecmp (item->key, "Interval") == 0) @@ -2549,7 +2536,6 @@ static int cna_config_quota (host_config_t *host, oconfig_item_t *ci) /* {{{ */ /* Corresponds to a block */ static int cna_config_disk(host_config_t *host, oconfig_item_t *ci) { /* {{{ */ cfg_disk_t *cfg_disk; - int i; if ((host == NULL) || (ci == NULL)) return (EINVAL); @@ -2569,7 +2555,7 @@ static int cna_config_disk(host_config_t *host, oconfig_item_t *ci) { /* {{{ */ } cfg_disk = host->cfg_disk; - for (i = 0; i < ci->children_num; ++i) { + for (int i = 0; i < ci->children_num; ++i) { oconfig_item_t *item = ci->children + i; /* if (!item || !item->key || !*item->key) continue; */ @@ -2594,7 +2580,6 @@ static int cna_config_disk(host_config_t *host, oconfig_item_t *ci) { /* {{{ */ static int cna_config_wafl(host_config_t *host, oconfig_item_t *ci) /* {{{ */ { cfg_wafl_t *cfg_wafl; - int i; if ((host == NULL) || (ci == NULL)) return (EINVAL); @@ -2612,7 +2597,7 @@ static int cna_config_wafl(host_config_t *host, oconfig_item_t *ci) /* {{{ */ } cfg_wafl = host->cfg_wafl; - for (i = 0; i < ci->children_num; ++i) { + for (int i = 0; i < ci->children_num; ++i) { oconfig_item_t *item = ci->children + i; if (strcasecmp(item->key, "Interval") == 0) @@ -2662,7 +2647,6 @@ static int cna_config_volume_usage(host_config_t *host, /* {{{ */ const oconfig_item_t *ci) { cfg_volume_usage_t *cfg_volume_usage; - int i; if ((host == NULL) || (ci == NULL)) return (EINVAL); @@ -2696,7 +2680,7 @@ static int cna_config_volume_usage(host_config_t *host, /* {{{ */ } cfg_volume_usage = host->cfg_volume_usage; - for (i = 0; i < ci->children_num; ++i) { + for (int i = 0; i < ci->children_num; ++i) { oconfig_item_t *item = ci->children + i; /* if (!item || !item->key || !*item->key) continue; */ @@ -2723,7 +2707,6 @@ static int cna_config_snapvault (host_config_t *host, /* {{{ */ const oconfig_item_t *ci) { cfg_snapvault_t *cfg_snapvault; - int i; if ((host == NULL) || (ci == NULL)) return EINVAL; @@ -2740,7 +2723,7 @@ static int cna_config_snapvault (host_config_t *host, /* {{{ */ cfg_snapvault = host->cfg_snapvault; - for (i = 0; i < ci->children_num; ++i) { + for (int i = 0; i < ci->children_num; ++i) { oconfig_item_t *item = ci->children + i; if (strcasecmp (item->key, "Interval") == 0) @@ -2758,7 +2741,6 @@ static int cna_config_system (host_config_t *host, /* {{{ */ oconfig_item_t *ci) { cfg_system_t *cfg_system; - int i; if ((host == NULL) || (ci == NULL)) return (EINVAL); @@ -2777,7 +2759,7 @@ static int cna_config_system (host_config_t *host, /* {{{ */ } cfg_system = host->cfg_system; - for (i = 0; i < ci->children_num; ++i) { + for (int i = 0; i < ci->children_num; ++i) { oconfig_item_t *item = ci->children + i; if (strcasecmp(item->key, "Interval") == 0) { @@ -2890,7 +2872,6 @@ static int cna_read (user_data_t *ud); static int cna_register_host (host_config_t *host) /* {{{ */ { char cb_name[256]; - user_data_t ud = { 0 }; if (host->vfiler) ssnprintf (cb_name, sizeof (cb_name), "netapp-%s-%s", @@ -2898,8 +2879,10 @@ static int cna_register_host (host_config_t *host) /* {{{ */ else ssnprintf (cb_name, sizeof (cb_name), "netapp-%s", host->name); - ud.data = host; - ud.free_func = (void (*) (void *)) free_host_config; + user_data_t ud = { + .data = host, + .free_func = (void (*) (void *)) free_host_config + }; plugin_register_complex_read (/* group = */ NULL, cb_name, /* callback = */ cna_read, @@ -2915,7 +2898,6 @@ static int cna_config_host (host_config_t *host, /* {{{ */ oconfig_item_t *item; _Bool is_vfiler = 0; int status; - int i; if (! strcasecmp (ci->key, "VFiler")) is_vfiler = 1; @@ -2929,7 +2911,7 @@ static int cna_config_host (host_config_t *host, /* {{{ */ if (status != 0) return (1); - for (i = 0; i < ci->children_num; ++i) { + for (int i = 0; i < ci->children_num; ++i) { item = ci->children + i; status = 0; @@ -3138,10 +3120,9 @@ static int cna_read (user_data_t *ud) { /* {{{ */ } /* }}} int cna_read */ static int cna_config (oconfig_item_t *ci) { /* {{{ */ - int i; oconfig_item_t *item; - for (i = 0; i < ci->children_num; ++i) { + for (int i = 0; i < ci->children_num; ++i) { item = ci->children + i; if (strcasecmp(item->key, "Host") == 0)