From 27ca3ca92a757b5c9bb3baa5a29ef352ec70b1c9 Mon Sep 17 00:00:00 2001 From: Zebity Spring Date: Fri, 17 May 2019 01:59:58 +1000 Subject: [PATCH 1/1] Run all changed files 68 8.c/1*.h through format.sh web util --- src/aggregation.c | 7 +- src/amqp.c | 10 +-- src/amqp1.c | 14 ++-- src/collectdctl.c | 20 ++--- src/daemon/configfile.c | 14 ++-- src/disk.c | 20 +++-- src/gmond.c | 4 +- src/intel_pmu.c | 2 +- src/intel_rdt.c | 10 +-- src/interface.c | 17 ++--- src/lua.c | 21 +++--- src/modbus.c | 3 +- src/mysql.c | 6 +- src/netapp.c | 47 ++++++------ src/netlink.c | 3 +- src/notify_desktop.c | 2 +- src/openldap.c | 3 +- src/ovs_stats.c | 4 +- src/perl.c | 2 +- src/protocols.c | 3 +- src/python.c | 16 ++-- src/redis.c | 3 +- src/routeros.c | 6 +- src/rrdcached.c | 3 +- src/snmp.c | 3 +- src/snmp_agent.c | 2 +- src/threshold.c | 15 ++-- src/utils/cmds/cmds_test.c | 166 +++++++++-------------------------------- src/utils/common/common.c | 14 ++-- src/utils/dpdk/dpdk.c | 3 +- src/utils/oauth/oauth.c | 3 +- src/utils/ovs/ovs.c | 4 +- src/varnish.c | 8 +- src/virt.c | 179 +++++++++++++++++++++++---------------------- src/write_kafka.c | 10 +-- src/write_prometheus.c | 3 +- src/write_redis.c | 10 +-- 37 files changed, 265 insertions(+), 395 deletions(-) diff --git a/src/aggregation.c b/src/aggregation.c index 2c8ef880..7a214ca3 100644 --- a/src/aggregation.c +++ b/src/aggregation.c @@ -398,9 +398,10 @@ static int agg_instance_read(agg_instance_t *inst, cdtime_t t) /* {{{ */ READ_FUNC(average, (inst->sum / ((gauge_t)inst->num))); READ_FUNC(min, inst->min); READ_FUNC(max, inst->max); - READ_FUNC(stddev, sqrt((((gauge_t)inst->num) * inst->squares_sum) - - (inst->sum * inst->sum)) / - ((gauge_t)inst->num)); + READ_FUNC(stddev, + sqrt((((gauge_t)inst->num) * inst->squares_sum) - + (inst->sum * inst->sum)) / + ((gauge_t)inst->num)); } /* Reset internal state. */ diff --git a/src/amqp.c b/src/amqp.c index 2077d57b..4bdb66c7 100644 --- a/src/amqp.c +++ b/src/amqp.c @@ -973,11 +973,11 @@ static int camqp_config_connection(oconfig_item_t *ci, /* {{{ */ char cbname[128]; ssnprintf(cbname, sizeof(cbname), "amqp/%s", conf->name); - status = plugin_register_write(cbname, camqp_write, - &(user_data_t){ - .data = conf, - .free_func = camqp_config_free, - }); + status = + plugin_register_write(cbname, camqp_write, + &(user_data_t){ + .data = conf, .free_func = camqp_config_free, + }); if (status != 0) { camqp_config_free(conf); return status; diff --git a/src/amqp1.c b/src/amqp1.c index 67c96b75..601f0ae0 100644 --- a/src/amqp1.c +++ b/src/amqp1.c @@ -639,16 +639,14 @@ static int amqp1_config_instance(oconfig_item_t *ci) /* {{{ */ status = plugin_register_notification( tpname, amqp1_notify, &(user_data_t){ - .data = instance, - .free_func = amqp1_config_instance_free, + .data = instance, .free_func = amqp1_config_instance_free, }); } else { - status = - plugin_register_write(tpname, amqp1_write, - &(user_data_t){ - .data = instance, - .free_func = amqp1_config_instance_free, - }); + status = plugin_register_write( + tpname, amqp1_write, + &(user_data_t){ + .data = instance, .free_func = amqp1_config_instance_free, + }); } if (status != 0) { diff --git a/src/collectdctl.c b/src/collectdctl.c index df83b50b..1ced5838 100644 --- a/src/collectdctl.c +++ b/src/collectdctl.c @@ -293,9 +293,8 @@ static int flush(lcc_connection_t *c, int argc, char **argv) { value); BAIL_OUT(-1); } else if ((endptr != NULL) && (*endptr != '\0')) { - fprintf(stderr, - "WARNING: Ignoring trailing garbage after timeout: " - "%s.\n", + fprintf(stderr, "WARNING: Ignoring trailing garbage after timeout: " + "%s.\n", endptr); } } else if (strcasecmp(key, "plugin") == 0) { @@ -342,9 +341,8 @@ static int flush(lcc_connection_t *c, int argc, char **argv) { char id[1024]; lcc_identifier_to_string(c, id, sizeof(id), identifiers + j); - fprintf(stderr, - "ERROR: Failed to flush plugin `%s', " - "identifier `%s': %s.\n", + fprintf(stderr, "ERROR: Failed to flush plugin `%s', " + "identifier `%s': %s.\n", (plugins[i] == NULL) ? "(all)" : plugins[i], id, lcc_strerror(c)); } @@ -388,9 +386,8 @@ static int listval(lcc_connection_t *c, int argc, char **argv) { status = lcc_identifier_to_string(c, id, sizeof(id), ret_ident + i); if (status != 0) { - fprintf(stderr, - "ERROR: listval: Failed to convert returned " - "identifier to a string: %s\n", + fprintf(stderr, "ERROR: listval: Failed to convert returned " + "identifier to a string: %s\n", lcc_strerror(c)); continue; } @@ -448,9 +445,8 @@ static int putval(lcc_connection_t *c, int argc, char **argv) { value); return -1; } else if ((endptr != NULL) && (*endptr != '\0')) { - fprintf(stderr, - "WARNING: Ignoring trailing garbage after " - "interval: %s.\n", + fprintf(stderr, "WARNING: Ignoring trailing garbage after " + "interval: %s.\n", endptr); } } else { diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index 4ec9ad1c..697daad3 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -267,8 +267,7 @@ static int dispatch_loadplugin(oconfig_item_t *ci) { /* default to the global interval set before loading this plugin */ plugin_ctx_t ctx = { - .interval = cf_get_default_interval(), - .name = strdup(name), + .interval = cf_get_default_interval(), .name = strdup(name), }; if (ctx.name == NULL) return ENOMEM; @@ -476,9 +475,9 @@ static int cf_ci_replace_child(oconfig_item_t *dst, oconfig_item_t *src, return 0; } - temp = - realloc(dst->children, sizeof(oconfig_item_t) * - (dst->children_num + src->children_num - 1)); + temp = realloc(dst->children, + sizeof(oconfig_item_t) * + (dst->children_num + src->children_num - 1)); if (temp == NULL) { ERROR("configfile: realloc failed."); return -1; @@ -517,8 +516,9 @@ static int cf_ci_append_children(oconfig_item_t *dst, oconfig_item_t *src) { if ((src == NULL) || (src->children_num == 0)) return 0; - temp = realloc(dst->children, sizeof(oconfig_item_t) * - (dst->children_num + src->children_num)); + temp = + realloc(dst->children, + sizeof(oconfig_item_t) * (dst->children_num + src->children_num)); if (temp == NULL) { ERROR("configfile: realloc failed."); return -1; diff --git a/src/disk.c b/src/disk.c index 84bc3f58..c3127b62 100644 --- a/src/disk.c +++ b/src/disk.c @@ -209,7 +209,7 @@ static int disk_init(void) { io_master_port = MACH_PORT_NULL; return -1; } - /* #endif HAVE_IOKIT_IOKITLIB_H */ +/* #endif HAVE_IOKIT_IOKITLIB_H */ #elif KERNEL_LINUX #if HAVE_LIBUDEV_H @@ -221,7 +221,7 @@ static int disk_init(void) { } } #endif /* HAVE_LIBUDEV_H */ - /* #endif KERNEL_LINUX */ +/* #endif KERNEL_LINUX */ #elif KERNEL_FREEBSD int rv; @@ -236,7 +236,7 @@ static int disk_init(void) { ERROR("geom_stats_open() failed, returned %d", rv); return -1; } - /* #endif KERNEL_FREEBSD */ +/* #endif KERNEL_FREEBSD */ #elif HAVE_LIBKSTAT kstat_t *ksp_chain; @@ -275,8 +275,7 @@ static void disk_submit(const char *plugin_instance, const char *type, derive_t read, derive_t write) { value_list_t vl = VALUE_LIST_INIT; value_t values[] = { - {.derive = read}, - {.derive = write}, + {.derive = read}, {.derive = write}, }; vl.values = values; @@ -293,8 +292,7 @@ static void submit_io_time(char const *plugin_instance, derive_t io_time, derive_t weighted_time) { value_list_t vl = VALUE_LIST_INIT; value_t values[] = { - {.derive = io_time}, - {.derive = weighted_time}, + {.derive = io_time}, {.derive = weighted_time}, }; vl.values = values; @@ -535,7 +533,7 @@ static int disk_read(void) { disk_submit(disk_name, "disk_time", read_tme / 1000, write_tme / 1000); } IOObjectRelease(disk_list); - /* #endif HAVE_IOKIT_IOKITLIB_H */ +/* #endif HAVE_IOKIT_IOKITLIB_H */ #elif KERNEL_FREEBSD int retry, dirty; @@ -899,7 +897,7 @@ static int disk_read(void) { free(missing_ds); } fclose(fh); - /* #endif defined(KERNEL_LINUX) */ +/* #endif defined(KERNEL_LINUX) */ #elif HAVE_LIBKSTAT #if HAVE_KSTAT_IO_T_WRITES && HAVE_KSTAT_IO_T_NWRITES && HAVE_KSTAT_IO_T_WTIME @@ -947,7 +945,7 @@ static int disk_read(void) { disk_submit(ksp[i]->ks_name, "disk_ops", kio.KIO_ROPS, kio.KIO_WOPS); } } - /* #endif defined(HAVE_LIBKSTAT) */ +/* #endif defined(HAVE_LIBKSTAT) */ #elif defined(HAVE_LIBSTATGRAB) sg_disk_io_stats *ds; @@ -974,7 +972,7 @@ static int disk_read(void) { disk_submit(name, "disk_octets", ds->read_bytes, ds->write_bytes); ds++; } - /* #endif defined(HAVE_LIBSTATGRAB) */ +/* #endif defined(HAVE_LIBSTATGRAB) */ #elif defined(HAVE_PERFSTAT) derive_t read_sectors; diff --git a/src/gmond.c b/src/gmond.c index 1aaf86d1..03dedcca 100644 --- a/src/gmond.c +++ b/src/gmond.c @@ -659,9 +659,7 @@ static int mc_handle_metadata_msg(Ganglia_metadata_msg *msg) /* {{{ */ break; } - default: { - return -1; - } + default: { return -1; } } return 0; diff --git a/src/intel_pmu.c b/src/intel_pmu.c index 350c1e39..f04f8871 100644 --- a/src/intel_pmu.c +++ b/src/intel_pmu.c @@ -26,8 +26,8 @@ * Kamil Wiatrowski **/ -#include "utils/common/common.h" #include "collectd.h" +#include "utils/common/common.h" #include "utils/config_cores/config_cores.h" diff --git a/src/intel_rdt.c b/src/intel_rdt.c index 38f987f6..743c8bc6 100644 --- a/src/intel_rdt.c +++ b/src/intel_rdt.c @@ -28,11 +28,11 @@ * Michał Aleksiński **/ -#include +#include "collectd.h" #include "utils/common/common.h" #include "utils/config_cores/config_cores.h" #include "utils/proc_pids/proc_pids.h" -#include "collectd.h" +#include #define RDT_PLUGIN "intel_rdt" @@ -851,9 +851,9 @@ static void rdt_init_pids_monitoring() { } /* update global proc_pids table */ - proc_pids_t **proc_pids = - realloc(g_rdt->proc_pids, (g_rdt->num_proc_pids + ng->num_names) * - sizeof(*g_rdt->proc_pids)); + proc_pids_t **proc_pids = realloc(g_rdt->proc_pids, + (g_rdt->num_proc_pids + ng->num_names) * + sizeof(*g_rdt->proc_pids)); if (NULL == proc_pids) { ERROR(RDT_PLUGIN ": Alloc error\n"); continue; diff --git a/src/interface.c b/src/interface.c index a18bcb44..5367ced3 100644 --- a/src/interface.c +++ b/src/interface.c @@ -82,9 +82,7 @@ static int pnif; * (Module-)Global variables */ static const char *config_keys[] = { - "Interface", - "IgnoreSelected", - "ReportInactive", + "Interface", "IgnoreSelected", "ReportInactive", }; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); @@ -162,8 +160,7 @@ static void if_submit(const char *dev, const char *type, derive_t rx, derive_t tx) { value_list_t vl = VALUE_LIST_INIT; value_t values[] = { - {.derive = rx}, - {.derive = tx}, + {.derive = rx}, {.derive = tx}, }; if (ignorelist_match(ignorelist, dev) != 0) @@ -191,7 +188,7 @@ static int interface_read(void) { #define IFA_TX_PACKT ifi_opackets #define IFA_RX_ERROR ifi_ierrors #define IFA_TX_ERROR ifi_oerrors - /* #endif HAVE_STRUCT_IF_DATA */ +/* #endif HAVE_STRUCT_IF_DATA */ #elif HAVE_STRUCT_NET_DEVICE_STATS #define IFA_DATA net_device_stats @@ -229,7 +226,7 @@ static int interface_read(void) { } freeifaddrs(if_list); - /* #endif HAVE_GETIFADDRS */ +/* #endif HAVE_GETIFADDRS */ #elif KERNEL_LINUX FILE *fh; @@ -285,7 +282,7 @@ static int interface_read(void) { } fclose(fh); - /* #endif KERNEL_LINUX */ +/* #endif KERNEL_LINUX */ #elif HAVE_LIBKSTAT derive_t rx; @@ -335,7 +332,7 @@ static int interface_read(void) { if ((rx != -1LL) || (tx != -1LL)) if_submit(iname, "if_errors", rx, tx); } - /* #endif HAVE_LIBKSTAT */ +/* #endif HAVE_LIBKSTAT */ #elif defined(HAVE_LIBSTATGRAB) sg_network_io_stats *ios; @@ -348,7 +345,7 @@ static int interface_read(void) { continue; if_submit(ios[i].interface_name, "if_octets", ios[i].rx, ios[i].tx); } - /* #endif HAVE_LIBSTATGRAB */ +/* #endif HAVE_LIBSTATGRAB */ #elif defined(HAVE_PERFSTAT) perfstat_id_t id; diff --git a/src/lua.c b/src/lua.c index a87f3ea7..9a43fc71 100644 --- a/src/lua.c +++ b/src/lua.c @@ -28,10 +28,10 @@ * Ruben Kerkhof **/ +#include "collectd.h" #include "plugin.h" #include "utils/common/common.h" #include "utils_lua.h" -#include "collectd.h" /* Include the Lua API header files. */ #include @@ -322,14 +322,14 @@ static int lua_cb_register_generic(lua_State *L, int type) /* {{{ */ pthread_mutex_init(&cb->lock, NULL); if (PLUGIN_READ == type) { - int status = plugin_register_complex_read(/* group = */ "lua", - /* name = */ function_name, - /* callback = */ clua_read, - /* interval = */ 0, - &(user_data_t){ - .data = cb, - .free_func = lua_cb_free, - }); + int status = + plugin_register_complex_read(/* group = */ "lua", + /* name = */ function_name, + /* callback = */ clua_read, + /* interval = */ 0, + &(user_data_t){ + .data = cb, .free_func = lua_cb_free, + }); if (status != 0) return luaL_error(L, "%s", "plugin_register_complex_read failed"); @@ -338,8 +338,7 @@ static int lua_cb_register_generic(lua_State *L, int type) /* {{{ */ int status = plugin_register_write(/* name = */ function_name, /* callback = */ clua_write, &(user_data_t){ - .data = cb, - .free_func = lua_cb_free, + .data = cb, .free_func = lua_cb_free, }); if (status != 0) diff --git a/src/modbus.c b/src/modbus.c index b551facd..5b2509b4 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -1078,8 +1078,7 @@ static int mb_config_add_host(oconfig_item_t *ci) /* {{{ */ /* callback = */ mb_read, /* interval = */ interval, &(user_data_t){ - .data = host, - .free_func = host_free, + .data = host, .free_func = host_free, }); } else { host_free(host); diff --git a/src/mysql.c b/src/mysql.c index 7b277a6d..65936274 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -225,8 +225,7 @@ static int mysql_config_database(oconfig_item_t *ci) /* {{{ */ plugin_register_complex_read( /* group = */ NULL, cb_name, mysql_read, /* interval = */ 0, &(user_data_t){ - .data = db, - .free_func = mysql_database_free, + .data = db, .free_func = mysql_database_free, }); } else { mysql_database_free(db); @@ -355,8 +354,7 @@ static void derive_submit(const char *type, const char *type_instance, static void traffic_submit(derive_t rx, derive_t tx, mysql_database_t *db) { value_t values[] = { - {.derive = rx}, - {.derive = tx}, + {.derive = rx}, {.derive = tx}, }; submit("mysql_octets", NULL, values, STATIC_ARRAY_SIZE(values), db); diff --git a/src/netapp.c b/src/netapp.c index 43aaa7a7..ae49b5e2 100644 --- a/src/netapp.c +++ b/src/netapp.c @@ -643,8 +643,7 @@ static int submit_two_derive(const char *host, derive_t val0, derive_t val1, cdtime_t timestamp, cdtime_t interval) { value_t values[] = { - {.derive = val0}, - {.derive = val1}, + {.derive = val0}, {.derive = val1}, }; return submit_values(host, plugin_inst, type, type_inst, values, @@ -667,8 +666,7 @@ static int submit_two_gauge(const char *host, const char *plugin_inst, /* {{{ */ gauge_t val0, gauge_t val1, cdtime_t timestamp, cdtime_t interval) { value_t values[] = { - {.gauge = val0}, - {.gauge = val1}, + {.gauge = val0}, {.gauge = val1}, }; return submit_values(host, plugin_inst, type, type_inst, values, @@ -780,8 +778,9 @@ static int submit_volume_perf_data(const char *hostname, /* {{{ */ /* Check for and submit disk-octet values */ if (HAS_ALL_FLAGS(old_data->flags, CFG_VOLUME_PERF_IO) && - HAS_ALL_FLAGS(new_data->flags, HAVE_VOLUME_PERF_BYTES_READ | - HAVE_VOLUME_PERF_BYTES_WRITE)) { + HAS_ALL_FLAGS(new_data->flags, + HAVE_VOLUME_PERF_BYTES_READ | + HAVE_VOLUME_PERF_BYTES_WRITE)) { submit_two_derive( hostname, plugin_instance, "disk_octets", /* type instance = */ NULL, (derive_t)new_data->read_bytes, (derive_t)new_data->write_bytes, @@ -799,15 +798,15 @@ static int submit_volume_perf_data(const char *hostname, /* {{{ */ } /* Check for, calculate and submit disk-latency values */ - if (HAS_ALL_FLAGS(old_data->flags, CFG_VOLUME_PERF_LATENCY | - HAVE_VOLUME_PERF_OPS_READ | - HAVE_VOLUME_PERF_OPS_WRITE | - HAVE_VOLUME_PERF_LATENCY_READ | - HAVE_VOLUME_PERF_LATENCY_WRITE) && - HAS_ALL_FLAGS(new_data->flags, HAVE_VOLUME_PERF_OPS_READ | - HAVE_VOLUME_PERF_OPS_WRITE | - HAVE_VOLUME_PERF_LATENCY_READ | - HAVE_VOLUME_PERF_LATENCY_WRITE)) { + if (HAS_ALL_FLAGS(old_data->flags, + CFG_VOLUME_PERF_LATENCY | HAVE_VOLUME_PERF_OPS_READ | + HAVE_VOLUME_PERF_OPS_WRITE | + HAVE_VOLUME_PERF_LATENCY_READ | + HAVE_VOLUME_PERF_LATENCY_WRITE) && + HAS_ALL_FLAGS(new_data->flags, + HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE | + HAVE_VOLUME_PERF_LATENCY_READ | + HAVE_VOLUME_PERF_LATENCY_WRITE)) { gauge_t latency_per_op_read; gauge_t latency_per_op_write; @@ -1407,8 +1406,9 @@ static int cna_submit_volume_usage_data(const char *hostname, /* {{{ */ ssnprintf(plugin_instance, sizeof(plugin_instance), "volume-%s", v->name); - if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SNAP_USED | - HAVE_VOLUME_USAGE_SNAP_RSVD)) { + if (HAS_ALL_FLAGS(v->flags, + HAVE_VOLUME_USAGE_SNAP_USED | + HAVE_VOLUME_USAGE_SNAP_RSVD)) { if (v->snap_reserved > v->snap_used) { snap_reserve_free = v->snap_reserved - v->snap_used; snap_reserve_used = v->snap_used; @@ -1422,8 +1422,9 @@ static int cna_submit_volume_usage_data(const char *hostname, /* {{{ */ /* The space used by snapshots but not reserved for them is included in * both, norm_used and snap_norm_used. If possible, subtract this here. */ - if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_NORM_USED | - HAVE_VOLUME_USAGE_SNAP_USED)) { + if (HAS_ALL_FLAGS(v->flags, + HAVE_VOLUME_USAGE_NORM_USED | + HAVE_VOLUME_USAGE_SNAP_USED)) { if (norm_used >= snap_norm_used) norm_used -= snap_norm_used; else { @@ -1465,8 +1466,9 @@ static int cna_submit_volume_usage_data(const char *hostname, /* {{{ */ "df_complex", "snap_reserved", (double)snap_reserve_free, /* timestamp = */ 0, interval); - if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SNAP_USED | - HAVE_VOLUME_USAGE_SNAP_RSVD)) + if (HAS_ALL_FLAGS(v->flags, + HAVE_VOLUME_USAGE_SNAP_USED | + HAVE_VOLUME_USAGE_SNAP_RSVD)) submit_double(hostname, /* plugin instance = */ plugin_instance, "df_complex", "snap_reserve_used", (double)snap_reserve_used, /* timestamp = */ 0, interval); @@ -2796,8 +2798,7 @@ static int cna_register_host(host_config_t *host) /* {{{ */ /* callback = */ cna_read, /* interval = */ host->interval, &(user_data_t){ - .data = host, - .free_func = (void *)free_host_config, + .data = host, .free_func = (void *)free_host_config, }); return 0; diff --git a/src/netlink.c b/src/netlink.c index 806265a2..e8a2877f 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -198,8 +198,7 @@ static void submit_two(const char *dev, const char *type, const char *type_instance, derive_t rx, derive_t tx) { value_list_t vl = VALUE_LIST_INIT; value_t values[] = { - {.derive = rx}, - {.derive = tx}, + {.derive = rx}, {.derive = tx}, }; vl.values = values; diff --git a/src/notify_desktop.c b/src/notify_desktop.c index e430b681..266c77cf 100644 --- a/src/notify_desktop.c +++ b/src/notify_desktop.c @@ -102,7 +102,7 @@ static int c_notify(const notification_t *n, notification = notify_notification_new(summary, n->message, NULL #if NOTIFY_CHECK_VERSION(0, 7, 0) - ); + ); #else , NULL); diff --git a/src/openldap.c b/src/openldap.c index cd72cdbe..41e2ec07 100644 --- a/src/openldap.c +++ b/src/openldap.c @@ -472,8 +472,7 @@ static int cldap_config_add(oconfig_item_t *ci) /* {{{ */ /* callback = */ cldap_read_host, /* interval = */ 0, &(user_data_t){ - .data = st, - .free_func = cldap_free, + .data = st, .free_func = cldap_free, }); } /* }}} int cldap_config_add */ diff --git a/src/ovs_stats.c b/src/ovs_stats.c index e22e851e..4ec14f4f 100644 --- a/src/ovs_stats.c +++ b/src/ovs_stats.c @@ -282,9 +282,7 @@ static void ovs_stats_submit_interfaces(port_list_t *port) { } strjoin(devname, sizeof(devname), (char *[]){ - bridge->name, - port->name, - iface->name, + bridge->name, port->name, iface->name, }, 3, "."); ovs_stats_submit_one(devname, "if_collisions", NULL, diff --git a/src/perl.c b/src/perl.c index d0c99178..0a4ae71d 100644 --- a/src/perl.c +++ b/src/perl.c @@ -33,8 +33,8 @@ /* do not automatically get the thread specific Perl interpreter */ #define PERL_NO_GET_CONTEXT -#include #include "collectd.h" +#include #include #include diff --git a/src/protocols.c b/src/protocols.c index 7bfa663c..8d3dafa7 100644 --- a/src/protocols.c +++ b/src/protocols.c @@ -41,8 +41,7 @@ * Global variables */ static const char *config_keys[] = { - "Value", - "IgnoreSelected", + "Value", "IgnoreSelected", }; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); diff --git a/src/python.c b/src/python.c index 70db6b6f..5669f45a 100644 --- a/src/python.c +++ b/src/python.c @@ -703,9 +703,8 @@ static PyObject *cpy_get_dataset(PyObject *self, PyObject *args) { for (size_t i = 0; i < ds->ds_num; ++i) { tuple = PyTuple_New(4); PyTuple_SET_ITEM(tuple, 0, cpy_string_to_unicode_or_bytes(ds->ds[i].name)); - PyTuple_SET_ITEM( - tuple, 1, - cpy_string_to_unicode_or_bytes(DS_TYPE_TO_STRING(ds->ds[i].type))); + PyTuple_SET_ITEM(tuple, 1, cpy_string_to_unicode_or_bytes( + DS_TYPE_TO_STRING(ds->ds[i].type))); PyTuple_SET_ITEM(tuple, 2, float_or_none(ds->ds[i].min)); PyTuple_SET_ITEM(tuple, 3, float_or_none(ds->ds[i].max)); PyList_SET_ITEM(list, i, tuple); @@ -775,8 +774,7 @@ static PyObject *cpy_register_generic_userdata(void *reg, void *handler, register_function(buf, handler, &(user_data_t){ - .data = c, - .free_func = cpy_destroy_user_data, + .data = c, .free_func = cpy_destroy_user_data, }); ++cpy_num_callbacks; @@ -819,8 +817,7 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args, /* group = */ "python", buf, cpy_read_callback, DOUBLE_TO_CDTIME_T(interval), &(user_data_t){ - .data = c, - .free_func = cpy_destroy_user_data, + .data = c, .free_func = cpy_destroy_user_data, }); ++cpy_num_callbacks; return cpy_string_to_unicode_or_bytes(buf); @@ -1204,9 +1201,8 @@ static PyObject *cpy_oconfig_to_pyconfig(oconfig_item_t *ci, PyObject *parent) { values = PyTuple_New(ci->values_num); /* New reference. */ for (int i = 0; i < ci->values_num; ++i) { if (ci->values[i].type == OCONFIG_TYPE_STRING) { - PyTuple_SET_ITEM( - values, i, - cpy_string_to_unicode_or_bytes(ci->values[i].value.string)); + PyTuple_SET_ITEM(values, i, cpy_string_to_unicode_or_bytes( + ci->values[i].value.string)); } else if (ci->values[i].type == OCONFIG_TYPE_NUMBER) { PyTuple_SET_ITEM(values, i, PyFloat_FromDouble(ci->values[i].value.number)); diff --git a/src/redis.c b/src/redis.c index 77ce5fb6..12f68946 100644 --- a/src/redis.c +++ b/src/redis.c @@ -123,8 +123,7 @@ static int redis_node_add(redis_node_t *rn) /* {{{ */ /* callback = */ redis_read, /* interval = */ 0, &(user_data_t){ - .data = rn, - .free_func = redis_node_free, + .data = rn, .free_func = redis_node_free, }); } /* }}} */ diff --git a/src/routeros.c b/src/routeros.c index ece865b6..fa28f044 100644 --- a/src/routeros.c +++ b/src/routeros.c @@ -53,8 +53,7 @@ static void cr_submit_io(cr_data_t *rd, const char *type, /* {{{ */ const char *type_instance, derive_t rx, derive_t tx) { value_list_t vl = VALUE_LIST_INIT; value_t values[] = { - {.derive = rx}, - {.derive = tx}, + {.derive = rx}, {.derive = tx}, }; vl.values = values; @@ -443,8 +442,7 @@ static int cr_config_router(oconfig_item_t *ci) /* {{{ */ return plugin_register_complex_read( /* group = */ NULL, read_name, cr_read, /* interval = */ 0, &(user_data_t){ - .data = router_data, - .free_func = (void *)cr_free_data, + .data = router_data, .free_func = (void *)cr_free_data, }); } /* }}} int cr_config_router */ diff --git a/src/rrdcached.c b/src/rrdcached.c index 1e75ff83..6f34e675 100644 --- a/src/rrdcached.c +++ b/src/rrdcached.c @@ -426,8 +426,7 @@ static int rc_write(const data_set_t *ds, const value_list_t *vl, } char *values_array[2] = { - [0] = values, - [1] = NULL, + [0] = values, [1] = NULL, }; while (42) { diff --git a/src/snmp.c b/src/snmp.c index aeb04fdd..dd7e9984 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -876,8 +876,7 @@ static int csnmp_config_add_host(oconfig_item_t *ci) { status = plugin_register_complex_read( /* group = */ NULL, cb_name, csnmp_read_host, interval, &(user_data_t){ - .data = hd, - .free_func = csnmp_host_definition_destroy, + .data = hd, .free_func = csnmp_host_definition_destroy, }); if (status != 0) { ERROR("snmp plugin: Registering complex read function failed."); diff --git a/src/snmp_agent.c b/src/snmp_agent.c index d75c16ec..bb4a7e42 100644 --- a/src/snmp_agent.c +++ b/src/snmp_agent.c @@ -29,11 +29,11 @@ #include "collectd.h" -#include #include "utils/avltree/avltree.h" #include "utils/common/common.h" #include "utils_cache.h" #include "utils_llist.h" +#include #include diff --git a/src/threshold.c b/src/threshold.c index e74dfc2c..b08d353d 100644 --- a/src/threshold.c +++ b/src/threshold.c @@ -367,9 +367,8 @@ static int ut_report_state(const data_set_t *ds, const value_list_t *vl, if (state_old == STATE_MISSING) ssnprintf(buf, bufsize, ": Value is no longer missing."); else - ssnprintf(buf, bufsize, - ": All data sources are within range again. " - "Current value of \"%s\" is %f.", + ssnprintf(buf, bufsize, ": All data sources are within range again. " + "Current value of \"%s\" is %f.", ds->ds[ds_index].name, values[ds_index]); } else if (state == STATE_UNKNOWN) { ERROR("ut_report_state: metric transition to UNKNOWN from a different " @@ -392,9 +391,8 @@ static int ut_report_state(const data_set_t *ds, const value_list_t *vl, ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "", max, ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : ""); } else { - ssnprintf(buf, bufsize, - ": Data source \"%s\" is currently " - "%f. That is %s the %s threshold of %f%s.", + ssnprintf(buf, bufsize, ": Data source \"%s\" is currently " + "%f. That is %s the %s threshold of %f%s.", ds->ds[ds_index].name, values[ds_index], isnan(min) ? "below" : "above", (state == STATE_ERROR) ? "failure" : "warning", @@ -427,9 +425,8 @@ static int ut_report_state(const data_set_t *ds, const value_list_t *vl, (value < min) ? min : max); } else /* is not inverted */ { - ssnprintf(buf, bufsize, - ": Data source \"%s\" is currently " - "%f. That is %s the %s threshold of %f.", + ssnprintf(buf, bufsize, ": Data source \"%s\" is currently " + "%f. That is %s the %s threshold of %f.", ds->ds[ds_index].name, values[ds_index], (values[ds_index] < min) ? "below" : "above", (state == STATE_ERROR) ? "failure" : "warning", diff --git a/src/utils/cmds/cmds_test.c b/src/utils/cmds/cmds_test.c index b534d718..048150ab 100644 --- a/src/utils/cmds/cmds_test.c +++ b/src/utils/cmds/cmds_test.c @@ -51,201 +51,114 @@ static struct { } parse_data[] = { /* Valid FLUSH commands. */ { - "FLUSH", - NULL, - CMD_OK, - CMD_FLUSH, + "FLUSH", NULL, CMD_OK, CMD_FLUSH, }, { - "FLUSH identifier=myhost/magic/MAGIC", - NULL, - CMD_OK, - CMD_FLUSH, + "FLUSH identifier=myhost/magic/MAGIC", NULL, CMD_OK, CMD_FLUSH, }, { - "FLUSH identifier=magic/MAGIC", - &default_host_opts, - CMD_OK, - CMD_FLUSH, + "FLUSH identifier=magic/MAGIC", &default_host_opts, CMD_OK, CMD_FLUSH, }, { - "FLUSH timeout=123 plugin=\"A\"", - NULL, - CMD_OK, - CMD_FLUSH, + "FLUSH timeout=123 plugin=\"A\"", NULL, CMD_OK, CMD_FLUSH, }, /* Invalid FLUSH commands. */ { /* Missing hostname; no default. */ - "FLUSH identifier=magic/MAGIC", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "FLUSH identifier=magic/MAGIC", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { /* Missing 'identifier' key. */ - "FLUSH myhost/magic/MAGIC", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "FLUSH myhost/magic/MAGIC", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { /* Invalid timeout. */ - "FLUSH timeout=A", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "FLUSH timeout=A", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { /* Invalid identifier. */ - "FLUSH identifier=invalid", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "FLUSH identifier=invalid", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { /* Invalid option. */ - "FLUSH invalid=option", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "FLUSH invalid=option", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, /* Valid GETVAL commands. */ { - "GETVAL myhost/magic/MAGIC", - NULL, - CMD_OK, - CMD_GETVAL, + "GETVAL myhost/magic/MAGIC", NULL, CMD_OK, CMD_GETVAL, }, { - "GETVAL magic/MAGIC", - &default_host_opts, - CMD_OK, - CMD_GETVAL, + "GETVAL magic/MAGIC", &default_host_opts, CMD_OK, CMD_GETVAL, }, /* Invalid GETVAL commands. */ { - "GETVAL magic/MAGIC", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "GETVAL magic/MAGIC", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { - "GETVAL", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "GETVAL", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { - "GETVAL invalid", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "GETVAL invalid", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, /* Valid LISTVAL commands. */ { - "LISTVAL", - NULL, - CMD_OK, - CMD_LISTVAL, + "LISTVAL", NULL, CMD_OK, CMD_LISTVAL, }, /* Invalid LISTVAL commands. */ { - "LISTVAL invalid", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "LISTVAL invalid", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, /* Valid PUTVAL commands. */ { - "PUTVAL magic/MAGIC N:42", - &default_host_opts, - CMD_OK, - CMD_PUTVAL, + "PUTVAL magic/MAGIC N:42", &default_host_opts, CMD_OK, CMD_PUTVAL, }, { - "PUTVAL myhost/magic/MAGIC N:42", - NULL, - CMD_OK, - CMD_PUTVAL, + "PUTVAL myhost/magic/MAGIC N:42", NULL, CMD_OK, CMD_PUTVAL, }, { - "PUTVAL myhost/magic/MAGIC 1234:42", - NULL, - CMD_OK, - CMD_PUTVAL, + "PUTVAL myhost/magic/MAGIC 1234:42", NULL, CMD_OK, CMD_PUTVAL, }, { - "PUTVAL myhost/magic/MAGIC 1234:42 2345:23", - NULL, - CMD_OK, - CMD_PUTVAL, + "PUTVAL myhost/magic/MAGIC 1234:42 2345:23", NULL, CMD_OK, CMD_PUTVAL, }, { - "PUTVAL myhost/magic/MAGIC interval=2 1234:42", - NULL, - CMD_OK, + "PUTVAL myhost/magic/MAGIC interval=2 1234:42", NULL, CMD_OK, CMD_PUTVAL, }, { - "PUTVAL myhost/magic/MAGIC interval=2 1234:42 interval=5 2345:23", - NULL, - CMD_OK, - CMD_PUTVAL, + "PUTVAL myhost/magic/MAGIC interval=2 1234:42 interval=5 2345:23", NULL, + CMD_OK, CMD_PUTVAL, }, /* Invalid PUTVAL commands. */ { - "PUTVAL magic/MAGIC N:42", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "PUTVAL magic/MAGIC N:42", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { - "PUTVAL", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "PUTVAL", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { - "PUTVAL invalid N:42", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "PUTVAL invalid N:42", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { - "PUTVAL myhost/magic/MAGIC A:42", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "PUTVAL myhost/magic/MAGIC A:42", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { - "PUTVAL myhost/magic/MAGIC 1234:A", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "PUTVAL myhost/magic/MAGIC 1234:A", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { - "PUTVAL myhost/magic/MAGIC", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "PUTVAL myhost/magic/MAGIC", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { - "PUTVAL 1234:A", - NULL, - CMD_PARSE_ERROR, - CMD_UNKNOWN, + "PUTVAL 1234:A", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, { - "PUTVAL myhost/magic/UNKNOWN 1234:42", - NULL, - CMD_PARSE_ERROR, + "PUTVAL myhost/magic/UNKNOWN 1234:42", NULL, CMD_PARSE_ERROR, CMD_UNKNOWN, }, /* @@ -260,16 +173,10 @@ static struct { /* Invalid commands. */ { - "INVALID", - NULL, - CMD_UNKNOWN_COMMAND, - CMD_UNKNOWN, + "INVALID", NULL, CMD_UNKNOWN_COMMAND, CMD_UNKNOWN, }, { - "INVALID interval=2", - NULL, - CMD_UNKNOWN_COMMAND, - CMD_UNKNOWN, + "INVALID interval=2", NULL, CMD_UNKNOWN_COMMAND, CMD_UNKNOWN, }, }; @@ -289,10 +196,9 @@ DEF_TEST(parse) { memset(&cmd, 0, sizeof(cmd)); status = cmd_parse(input, &cmd, parse_data[i].opts, &err); - ssnprintf(description, sizeof(description), - "cmd_parse (\"%s\", opts=%p) = " - "%d (type=%d [%s]); want %d " - "(type=%d [%s])", + ssnprintf(description, sizeof(description), "cmd_parse (\"%s\", opts=%p) = " + "%d (type=%d [%s]); want %d " + "(type=%d [%s])", parse_data[i].input, parse_data[i].opts, status, cmd.type, CMD_TO_STRING(cmd.type), parse_data[i].expected_status, parse_data[i].expected_type, diff --git a/src/utils/common/common.c b/src/utils/common/common.c index 0d2aaae6..6ee4e081 100644 --- a/src/utils/common/common.c +++ b/src/utils/common/common.c @@ -181,7 +181,7 @@ char *sstrerror(int errnum, char *buf, size_t buflen) { pthread_mutex_unlock(&strerror_r_lock); } - /* #endif !HAVE_STRERROR_R */ +/* #endif !HAVE_STRERROR_R */ #elif STRERROR_R_CHAR_P { @@ -191,19 +191,17 @@ char *sstrerror(int errnum, char *buf, size_t buflen) { if ((temp != NULL) && (temp != buf) && (temp[0] != '\0')) sstrncpy(buf, temp, buflen); else - sstrncpy(buf, - "strerror_r did not return " - "an error message", + sstrncpy(buf, "strerror_r did not return " + "an error message", buflen); } } - /* #endif STRERROR_R_CHAR_P */ +/* #endif STRERROR_R_CHAR_P */ #else if (strerror_r(errnum, buf, buflen) != 0) { - snprintf(buf, buflen, - "Error #%i; " - "Additionally, strerror_r failed.", + snprintf(buf, buflen, "Error #%i; " + "Additionally, strerror_r failed.", errnum); } #endif /* STRERROR_R_CHAR_P */ diff --git a/src/utils/dpdk/dpdk.c b/src/utils/dpdk/dpdk.c index 7d9f7abc..efc39dae 100644 --- a/src/utils/dpdk/dpdk.c +++ b/src/utils/dpdk/dpdk.c @@ -704,8 +704,7 @@ static void dpdk_helper_check_pipe(dpdk_helper_ctx_t *phc) { /* non blocking check on helper logging pipe */ struct pollfd fds = { - .fd = phc->pipes[0], - .events = POLLIN, + .fd = phc->pipes[0], .events = POLLIN, }; int data_avail = poll(&fds, 1, 0); DEBUG("%s:dpdk_helper_check_pipe: poll data_avail=%d", phc->shm_name, diff --git a/src/utils/oauth/oauth.c b/src/utils/oauth/oauth.c index a7ae75d0..e185c438 100644 --- a/src/utils/oauth/oauth.c +++ b/src/utils/oauth/oauth.c @@ -531,8 +531,7 @@ oauth_google_t oauth_create_google_json(char const *buffer, char const *scope) { } oauth_google_t ret = { - .project_id = strdup(project_id), - .oauth = oauth, + .project_id = strdup(project_id), .oauth = oauth, }; yajl_tree_free(root); diff --git a/src/utils/ovs/ovs.c b/src/utils/ovs/ovs.c index 52a590b1..127a9178 100644 --- a/src/utils/ovs/ovs.c +++ b/src/utils/ovs/ovs.c @@ -785,9 +785,7 @@ static void *ovs_poll_worker(void *arg) { ovs_db_t *pdb = (ovs_db_t *)arg; /* pointer to OVS DB */ ovs_json_reader_t *jreader = NULL; struct pollfd poll_fd = { - .fd = pdb->sock, - .events = POLLIN | POLLPRI, - .revents = 0, + .fd = pdb->sock, .events = POLLIN | POLLPRI, .revents = 0, }; /* create JSON reader instance */ diff --git a/src/varnish.c b/src/varnish.c index f4c70af8..4200c21e 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -1546,8 +1546,7 @@ static int varnish_init(void) /* {{{ */ /* callback = */ varnish_read, /* interval = */ 0, &(user_data_t){ - .data = conf, - .free_func = varnish_config_free, + .data = conf, .free_func = varnish_config_free, }); return 0; @@ -1752,7 +1751,7 @@ static int varnish_config_instance(const oconfig_item_t *ci) /* {{{ */ !conf->collect_mgt && !conf->collect_lck && !conf->collect_mempool && !conf->collect_mse #endif - ) { + ) { WARNING("Varnish plugin: No metric has been configured for " "instance \"%s\". Disabling this instance.", (conf->instance == NULL) ? "localhost" : conf->instance); @@ -1769,8 +1768,7 @@ static int varnish_config_instance(const oconfig_item_t *ci) /* {{{ */ /* callback = */ varnish_read, /* interval = */ 0, &(user_data_t){ - .data = conf, - .free_func = varnish_config_free, + .data = conf, .free_func = varnish_config_free, }); have_instance = true; diff --git a/src/virt.c b/src/virt.c index d24407ab..81bf18f8 100644 --- a/src/virt.c +++ b/src/virt.c @@ -131,16 +131,16 @@ static bool report_network_interfaces = true; static virt_notif_thread_t notif_thread; const char *domain_states[] = { - [VIR_DOMAIN_NOSTATE] = "no state", - [VIR_DOMAIN_RUNNING] = "the domain is running", - [VIR_DOMAIN_BLOCKED] = "the domain is blocked on resource", - [VIR_DOMAIN_PAUSED] = "the domain is paused by user", - [VIR_DOMAIN_SHUTDOWN] = "the domain is being shut down", - [VIR_DOMAIN_SHUTOFF] = "the domain is shut off", - [VIR_DOMAIN_CRASHED] = "the domain is crashed", + [VIR_DOMAIN_NOSTATE] = "no state", + [VIR_DOMAIN_RUNNING] = "the domain is running", + [VIR_DOMAIN_BLOCKED] = "the domain is blocked on resource", + [VIR_DOMAIN_PAUSED] = "the domain is paused by user", + [VIR_DOMAIN_SHUTDOWN] = "the domain is being shut down", + [VIR_DOMAIN_SHUTOFF] = "the domain is shut off", + [VIR_DOMAIN_CRASHED] = "the domain is crashed", #ifdef HAVE_DOM_STATE_PMSUSPENDED - [VIR_DOMAIN_PMSUSPENDED] = - "the domain is suspended by guest power management", + [VIR_DOMAIN_PMSUSPENDED] = + "the domain is suspended by guest power management", #endif }; @@ -352,99 +352,107 @@ static int map_domain_event_detail_to_reason(int event, int detail) { #define DOMAIN_STATE_REASON_MAX_SIZE 20 const char *domain_reasons[][DOMAIN_STATE_REASON_MAX_SIZE] = { - [VIR_DOMAIN_NOSTATE][VIR_DOMAIN_NOSTATE_UNKNOWN] = "the reason is unknown", - - [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_UNKNOWN] = "the reason is unknown", - [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_BOOTED] = - "normal startup from boot", - [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_MIGRATED] = - "migrated from another host", - [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_RESTORED] = - "restored from a state file", - [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_FROM_SNAPSHOT] = - "restored from snapshot", - [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_UNPAUSED] = - "returned from paused state", - [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_MIGRATION_CANCELED] = - "returned from migration", - [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_SAVE_CANCELED] = - "returned from failed save process", + [VIR_DOMAIN_NOSTATE][VIR_DOMAIN_NOSTATE_UNKNOWN] = + "the reason is unknown", + + [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_UNKNOWN] = + "the reason is unknown", + [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_BOOTED] = + "normal startup from boot", + [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_MIGRATED] = + "migrated from another host", + [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_RESTORED] = + "restored from a state file", + [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_FROM_SNAPSHOT] = + "restored from snapshot", + [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_UNPAUSED] = + "returned from paused state", + [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_MIGRATION_CANCELED] = + "returned from migration", + [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_SAVE_CANCELED] = + "returned from failed save process", #ifdef HAVE_DOM_REASON_RUNNING_WAKEUP - [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_WAKEUP] = - "returned from pmsuspended due to wakeup event", + [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_WAKEUP] = + "returned from pmsuspended due to wakeup event", #endif #ifdef HAVE_DOM_REASON_CRASHED - [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_CRASHED] = "resumed from crashed", + [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_CRASHED] = + "resumed from crashed", #endif #ifdef HAVE_DOM_REASON_POSTCOPY - [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_POSTCOPY] = - "running in post-copy migration mode", -#endif - [VIR_DOMAIN_BLOCKED][VIR_DOMAIN_BLOCKED_UNKNOWN] = "the reason is unknown", - - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_UNKNOWN] = "the reason is unknown", - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_USER] = "paused on user request", - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_MIGRATION] = - "paused for offline migration", - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_SAVE] = "paused for save", - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_DUMP] = - "paused for offline core dump", - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_IOERROR] = - "paused due to a disk I/O error", - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_WATCHDOG] = - "paused due to a watchdog event", - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_FROM_SNAPSHOT] = - "paused after restoring from snapshot", + [VIR_DOMAIN_RUNNING][VIR_DOMAIN_RUNNING_POSTCOPY] = + "running in post-copy migration mode", +#endif + [VIR_DOMAIN_BLOCKED][VIR_DOMAIN_BLOCKED_UNKNOWN] = + "the reason is unknown", + + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_UNKNOWN] = + "the reason is unknown", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_USER] = "paused on user request", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_MIGRATION] = + "paused for offline migration", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_SAVE] = "paused for save", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_DUMP] = + "paused for offline core dump", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_IOERROR] = + "paused due to a disk I/O error", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_WATCHDOG] = + "paused due to a watchdog event", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_FROM_SNAPSHOT] = + "paused after restoring from snapshot", #ifdef HAVE_DOM_REASON_PAUSED_SHUTTING_DOWN - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_SHUTTING_DOWN] = - "paused during shutdown process", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_SHUTTING_DOWN] = + "paused during shutdown process", #endif #ifdef HAVE_DOM_REASON_PAUSED_SNAPSHOT - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_SNAPSHOT] = - "paused while creating a snapshot", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_SNAPSHOT] = + "paused while creating a snapshot", #endif #ifdef HAVE_DOM_REASON_PAUSED_CRASHED - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_CRASHED] = - "paused due to a guest crash", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_CRASHED] = + "paused due to a guest crash", #endif #ifdef HAVE_DOM_REASON_PAUSED_STARTING_UP - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_STARTING_UP] = - "the domain is being started", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_STARTING_UP] = + "the domain is being started", #endif #ifdef HAVE_DOM_REASON_POSTCOPY - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_POSTCOPY] = - "paused for post-copy migration", - [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_POSTCOPY_FAILED] = - "paused after failed post-copy", -#endif - [VIR_DOMAIN_SHUTDOWN][VIR_DOMAIN_SHUTDOWN_UNKNOWN] = - "the reason is unknown", - [VIR_DOMAIN_SHUTDOWN][VIR_DOMAIN_SHUTDOWN_USER] = - "shutting down on user request", - - [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_UNKNOWN] = "the reason is unknown", - [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_SHUTDOWN] = "normal shutdown", - [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_DESTROYED] = "forced poweroff", - [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_CRASHED] = "domain crashed", - [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_MIGRATED] = - "migrated to another host", - [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_SAVED] = "saved to a file", - [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_FAILED] = "domain failed to start", - [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT] = - "restored from a snapshot which was taken while domain was shutoff", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_POSTCOPY] = + "paused for post-copy migration", + [VIR_DOMAIN_PAUSED][VIR_DOMAIN_PAUSED_POSTCOPY_FAILED] = + "paused after failed post-copy", +#endif + [VIR_DOMAIN_SHUTDOWN][VIR_DOMAIN_SHUTDOWN_UNKNOWN] = + "the reason is unknown", + [VIR_DOMAIN_SHUTDOWN][VIR_DOMAIN_SHUTDOWN_USER] = + "shutting down on user request", + + [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_UNKNOWN] = + "the reason is unknown", + [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_SHUTDOWN] = "normal shutdown", + [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_DESTROYED] = "forced poweroff", + [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_CRASHED] = "domain crashed", + [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_MIGRATED] = + "migrated to another host", + [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_SAVED] = "saved to a file", + [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_FAILED] = + "domain failed to start", + [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT] = + "restored from a snapshot which was taken while domain was shutoff", #ifdef HAVE_DOM_REASON_SHUTOFF_DAEMON - [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_DAEMON] = - "daemon decides to kill domain during reconnection processing", + [VIR_DOMAIN_SHUTOFF][VIR_DOMAIN_SHUTOFF_DAEMON] = + "daemon decides to kill domain during reconnection processing", #endif - [VIR_DOMAIN_CRASHED][VIR_DOMAIN_CRASHED_UNKNOWN] = "the reason is unknown", + [VIR_DOMAIN_CRASHED][VIR_DOMAIN_CRASHED_UNKNOWN] = + "the reason is unknown", #ifdef VIR_DOMAIN_CRASHED_PANICKED - [VIR_DOMAIN_CRASHED][VIR_DOMAIN_CRASHED_PANICKED] = "domain panicked", + [VIR_DOMAIN_CRASHED][VIR_DOMAIN_CRASHED_PANICKED] = "domain panicked", #endif #ifdef HAVE_DOM_STATE_PMSUSPENDED - [VIR_DOMAIN_PMSUSPENDED][VIR_DOMAIN_PMSUSPENDED_UNKNOWN] = - "the reason is unknown", + [VIR_DOMAIN_PMSUSPENDED][VIR_DOMAIN_PMSUSPENDED_UNKNOWN] = + "the reason is unknown", #endif }; #endif /* HAVE_DOM_REASON */ @@ -944,8 +952,7 @@ static void memory_stats_submit(gauge_t value, virDomainPtr dom, static void submit_derive2(const char *type, derive_t v0, derive_t v1, virDomainPtr dom, const char *devname) { value_t values[] = { - {.derive = v0}, - {.derive = v1}, + {.derive = v0}, {.derive = v1}, }; submit(dom, type, devname, values, STATIC_ARRAY_SIZE(values)); @@ -1671,8 +1678,7 @@ static int submit_domain_state(virDomainPtr domain) { } value_t values[] = { - {.gauge = (gauge_t)domain_state}, - {.gauge = (gauge_t)domain_reason}, + {.gauge = (gauge_t)domain_state}, {.gauge = (gauge_t)domain_reason}, }; submit(domain, "domain_state", NULL, values, STATIC_ARRAY_SIZE(values)); @@ -1748,8 +1754,7 @@ static int get_memory_stats(virDomainPtr domain) { if (min_flt > 0 || maj_flt > 0) { value_t values[] = { - {.gauge = (gauge_t)min_flt}, - {.gauge = (gauge_t)maj_flt}, + {.gauge = (gauge_t)min_flt}, {.gauge = (gauge_t)maj_flt}, }; submit(domain, "ps_pagefaults", NULL, values, STATIC_ARRAY_SIZE(values)); } diff --git a/src/write_kafka.c b/src/write_kafka.c index 09bb639a..592d669a 100644 --- a/src/write_kafka.c +++ b/src/write_kafka.c @@ -413,11 +413,11 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, ssnprintf(callback_name, sizeof(callback_name), "write_kafka/%s", tctx->topic_name); - status = plugin_register_write(callback_name, kafka_write, - &(user_data_t){ - .data = tctx, - .free_func = kafka_topic_context_free, - }); + status = plugin_register_write( + callback_name, kafka_write, + &(user_data_t){ + .data = tctx, .free_func = kafka_topic_context_free, + }); if (status != 0) { WARNING("write_kafka plugin: plugin_register_write (\"%s\") " "failed with status %i.", diff --git a/src/write_prometheus.c b/src/write_prometheus.c index b9040223..fe3b9407 100644 --- a/src/write_prometheus.c +++ b/src/write_prometheus.c @@ -156,8 +156,7 @@ static char *format_labels(char *buffer, size_t buffer_size, #define LABEL_BUFFER_SIZE (LABEL_KEY_SIZE + LABEL_VALUE_SIZE + 4) char *labels[3] = { - (char[LABEL_BUFFER_SIZE]){0}, - (char[LABEL_BUFFER_SIZE]){0}, + (char[LABEL_BUFFER_SIZE]){0}, (char[LABEL_BUFFER_SIZE]){0}, (char[LABEL_BUFFER_SIZE]){0}, }; diff --git a/src/write_redis.c b/src/write_redis.c index 32005cd6..880323ce 100644 --- a/src/write_redis.c +++ b/src/write_redis.c @@ -242,11 +242,11 @@ static int wr_config_node(oconfig_item_t *ci) /* {{{ */ ssnprintf(cb_name, sizeof(cb_name), "write_redis/%s", node->name); - status = plugin_register_write(cb_name, wr_write, - &(user_data_t){ - .data = node, - .free_func = wr_config_free, - }); + status = + plugin_register_write(cb_name, wr_write, + &(user_data_t){ + .data = node, .free_func = wr_config_free, + }); } if (status != 0) -- 2.11.0