From 956a2f4996d9fb0526b6f60c29be9b17c0ad27ba Mon Sep 17 00:00:00 2001 From: Zebity Spring Date: Thu, 16 May 2019 23:56:25 +1000 Subject: [PATCH] Run all changed files 68 8.c/1*.h through clang-format (cherry picked from commit eada465ff40eb2ecaef17490e5462dab3b8874fe) --- src/aggregation.c | 23 +-- src/amqp.c | 43 ++--- src/amqp1.c | 16 +- src/aquaero.c | 4 +- src/ascent.c | 2 +- src/ceph.c | 2 +- src/collectdctl.c | 22 +-- src/daemon/configfile.c | 6 +- src/disk.c | 23 +-- src/dpdkevents.c | 4 +- src/gmond.c | 6 +- src/intel_rdt.c | 12 +- src/interface.c | 19 ++- src/ipmi.c | 25 +-- src/iptables.c | 8 +- src/lua.c | 21 +-- src/lvm.c | 3 +- src/mic.c | 2 +- src/modbus.c | 3 +- src/mysql.c | 10 +- src/netapp.c | 60 +++---- src/netlink.c | 9 +- src/nginx.c | 2 +- src/notify_desktop.c | 12 +- src/notify_email.c | 34 ++-- src/onewire.c | 2 +- src/openldap.c | 14 +- src/ovs_events.c | 6 +- src/ovs_stats.c | 4 +- src/postgresql.c | 8 +- src/protocols.c | 5 +- src/python.c | 16 +- src/redis.c | 3 +- src/routeros.c | 10 +- src/rrdcached.c | 11 +- src/rrdtool.c | 16 +- src/sigrok.c | 6 +- src/smart.c | 4 +- src/snmp.c | 15 +- src/snmp_agent.c | 5 +- src/threshold.c | 63 ++++---- src/utils/cmds/cmds_test.c | 15 +- src/utils/common/common.c | 21 +-- src/utils/common/common.h | 2 +- src/utils/db_query/db_query.c | 2 +- src/utils/dpdk/dpdk.c | 13 +- src/utils/format_stackdriver/format_stackdriver.c | 8 +- src/utils/gce/gce.c | 2 +- src/utils/oauth/oauth.c | 13 +- src/utils/ovs/ovs.c | 4 +- src/utils/rrdcreate/rrdcreate.c | 2 +- src/varnish.c | 12 +- src/virt.c | 188 +++++++++++----------- src/write_kafka.c | 12 +- src/write_prometheus.c | 23 +-- src/write_redis.c | 13 +- src/write_riemann.c | 13 +- src/write_stackdriver.c | 7 +- 58 files changed, 479 insertions(+), 430 deletions(-) diff --git a/src/aggregation.c b/src/aggregation.c index c37caeb5..2c8ef880 100644 --- a/src/aggregation.c +++ b/src/aggregation.c @@ -198,15 +198,17 @@ static int agg_instance_create_name(agg_instance_t *inst, /* {{{ */ sstrncpy(inst->ident.plugin_instance, AGG_FUNC_PLACEHOLDER, sizeof(inst->ident.plugin_instance)); else if (strcmp("", tmp_plugin) != 0) - ssnprintf(inst->ident.plugin_instance, sizeof(inst->ident.plugin_instance), - "%s-%s", tmp_plugin, AGG_FUNC_PLACEHOLDER); + ssnprintf(inst->ident.plugin_instance, + sizeof(inst->ident.plugin_instance), "%s-%s", tmp_plugin, + AGG_FUNC_PLACEHOLDER); else if (strcmp("", tmp_plugin_instance) != 0) - ssnprintf(inst->ident.plugin_instance, sizeof(inst->ident.plugin_instance), - "%s-%s", tmp_plugin_instance, AGG_FUNC_PLACEHOLDER); + ssnprintf(inst->ident.plugin_instance, + sizeof(inst->ident.plugin_instance), "%s-%s", + tmp_plugin_instance, AGG_FUNC_PLACEHOLDER); else - ssnprintf(inst->ident.plugin_instance, sizeof(inst->ident.plugin_instance), - "%s-%s-%s", tmp_plugin, tmp_plugin_instance, - AGG_FUNC_PLACEHOLDER); + ssnprintf(inst->ident.plugin_instance, + sizeof(inst->ident.plugin_instance), "%s-%s-%s", tmp_plugin, + tmp_plugin_instance, AGG_FUNC_PLACEHOLDER); } /* Type */ @@ -396,10 +398,9 @@ 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 4c9ea0fd..39575b93 100644 --- a/src/amqp.c +++ b/src/amqp.c @@ -218,17 +218,17 @@ static char *camqp_strerror(camqp_config_t *conf, /* {{{ */ amqp_connection_close_t *m = r.reply.decoded; char *tmp = camqp_bytes_cstring(&m->reply_text); ssnprintf(buffer, buffer_size, "Server connection error %d: %s", - m->reply_code, tmp); + m->reply_code, tmp); sfree(tmp); } else if (r.reply.id == AMQP_CHANNEL_CLOSE_METHOD) { amqp_channel_close_t *m = r.reply.decoded; char *tmp = camqp_bytes_cstring(&m->reply_text); ssnprintf(buffer, buffer_size, "Server channel error %d: %s", - m->reply_code, tmp); + m->reply_code, tmp); sfree(tmp); } else { ssnprintf(buffer, buffer_size, "Server error method %#" PRIx32, - r.reply.id); + r.reply.id); } break; @@ -322,7 +322,8 @@ static int camqp_setup_queue(camqp_config_t *conf) /* {{{ */ qd_ret = amqp_queue_declare(conf->connection, /* channel = */ CAMQP_CHANNEL, - /* queue = */ (conf->queue != NULL) + /* queue = */ + (conf->queue != NULL) ? amqp_cstring_bytes(conf->queue) : AMQP_EMPTY_BYTES, /* passive = */ 0, @@ -353,15 +354,15 @@ static int camqp_setup_queue(camqp_config_t *conf) /* {{{ */ amqp_queue_bind_ok_t *qb_ret; assert(conf->queue != NULL); - qb_ret = - amqp_queue_bind(conf->connection, - /* channel = */ CAMQP_CHANNEL, - /* queue = */ amqp_cstring_bytes(conf->queue), - /* exchange = */ amqp_cstring_bytes(conf->exchange), - /* routing_key = */ (conf->routing_key != NULL) - ? amqp_cstring_bytes(conf->routing_key) - : AMQP_EMPTY_BYTES, - /* arguments = */ AMQP_EMPTY_TABLE); + qb_ret = amqp_queue_bind( + conf->connection, + /* channel = */ CAMQP_CHANNEL, + /* queue = */ amqp_cstring_bytes(conf->queue), + /* exchange = */ amqp_cstring_bytes(conf->exchange), + /* routing_key = */ + (conf->routing_key != NULL) ? amqp_cstring_bytes(conf->routing_key) + : AMQP_EMPTY_BYTES, + /* arguments = */ AMQP_EMPTY_TABLE); if ((qb_ret == NULL) && camqp_is_error(conf)) { char errbuf[1024]; ERROR("amqp plugin: amqp_queue_bind failed: %s", @@ -428,7 +429,7 @@ static int camqp_connect(camqp_config_t *conf) /* {{{ */ #ifdef HAVE_AMQP_TCP_SOCKET #define CLOSE_SOCKET() /* amqp_destroy_connection() closes the socket for us \ - */ + */ /* TODO: add support for SSL using amqp_ssl_socket_new * and related functions */ socket = amqp_tcp_socket_new(conf->connection); @@ -749,8 +750,8 @@ static int camqp_write(const data_set_t *ds, const value_list_t *vl, /* {{{ */ sstrncpy(routing_key, conf->routing_key, sizeof(routing_key)); } else { ssnprintf(routing_key, sizeof(routing_key), "collectd/%s/%s/%s/%s/%s", - vl->host, vl->plugin, vl->plugin_instance, vl->type, - vl->type_instance); + vl->host, vl->plugin, vl->plugin_instance, vl->type, + vl->type_instance); /* Switch slashes (the only character forbidden by collectd) and dots * (the separation character used by AMQP). */ @@ -972,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 11ff7c6b..67c96b75 100644 --- a/src/amqp1.c +++ b/src/amqp1.c @@ -630,7 +630,7 @@ static int amqp1_config_instance(oconfig_item_t *ci) /* {{{ */ return -1; } status = ssnprintf(instance->send_to, sizeof(instance->send_to), "/%s/%s", - transport->address, instance->name); + transport->address, instance->name); if ((status < 0) || (size_t)status >= sizeof(instance->send_to)) { ERROR("amqp1 plugin: send_to address would have been truncated."); return -1; @@ -639,14 +639,16 @@ 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/aquaero.c b/src/aquaero.c index fe75afe9..61dd76db 100644 --- a/src/aquaero.c +++ b/src/aquaero.c @@ -81,8 +81,8 @@ static void aquaero_submit_array(const char *type, if (value_array[i] == AQ5_FLOAT_UNDEF) continue; - ssnprintf(type_instance, sizeof(type_instance), "%s%d", type_instance_prefix, - i + 1); + ssnprintf(type_instance, sizeof(type_instance), "%s%d", + type_instance_prefix, i + 1); aquaero_submit(type, type_instance, value_array[i]); } } diff --git a/src/ascent.c b/src/ascent.c index 4006eb05..6240e319 100644 --- a/src/ascent.c +++ b/src/ascent.c @@ -500,7 +500,7 @@ static int ascent_init(void) /* {{{ */ int status; status = ssnprintf(credentials, sizeof(credentials), "%s:%s", user, - (pass == NULL) ? "" : pass); + (pass == NULL) ? "" : pass); if ((status < 0) || ((size_t)status >= sizeof(credentials))) { ERROR("ascent plugin: ascent_init: Returning an error because the " "credentials have been truncated."); diff --git a/src/ceph.c b/src/ceph.c index 67c4c27d..8048f5dd 100644 --- a/src/ceph.c +++ b/src/ceph.c @@ -1154,7 +1154,7 @@ static ssize_t cconn_handle_event(struct cconn *io) { case CSTATE_WRITE_REQUEST: { char cmd[32]; ssnprintf(cmd, sizeof(cmd), "%s%d%s", "{ \"prefix\": \"", io->request_type, - "\" }\n"); + "\" }\n"); size_t cmd_len = strlen(cmd); RETRY_ON_EINTR( ret, write(io->asok, ((char *)&cmd) + io->amt, cmd_len - io->amt)); diff --git a/src/collectdctl.c b/src/collectdctl.c index f7739a14..df83b50b 100644 --- a/src/collectdctl.c +++ b/src/collectdctl.c @@ -25,9 +25,9 @@ #include "config.h" #endif +#include #include #include -#include #include #include #include @@ -293,8 +293,9 @@ 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) { @@ -341,8 +342,9 @@ 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)); } @@ -386,8 +388,9 @@ 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; } @@ -445,8 +448,9 @@ 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 79ce14b7..1a3c4f45 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -314,11 +314,11 @@ static int dispatch_value_plugin(const char *plugin, oconfig_item_t *ci) { status = ssnprintf(buffer_ptr, buffer_free, " %s", ci->values[i].value.string); else if (ci->values[i].type == OCONFIG_TYPE_NUMBER) - status = - ssnprintf(buffer_ptr, buffer_free, " %lf", ci->values[i].value.number); + status = ssnprintf(buffer_ptr, buffer_free, " %lf", + ci->values[i].value.number); else if (ci->values[i].type == OCONFIG_TYPE_BOOLEAN) status = ssnprintf(buffer_ptr, buffer_free, " %s", - ci->values[i].value.boolean ? "true" : "false"); + ci->values[i].value.boolean ? "true" : "false"); if ((status < 0) || (status >= buffer_free)) return -1; diff --git a/src/disk.c b/src/disk.c index 2026580a..ddfaaf96 100644 --- a/src/disk.c +++ b/src/disk.c @@ -206,7 +206,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 @@ -218,7 +218,7 @@ static int disk_init(void) { } } #endif /* HAVE_LIBUDEV_H */ -/* #endif KERNEL_LINUX */ + /* #endif KERNEL_LINUX */ #elif KERNEL_FREEBSD int rv; @@ -233,7 +233,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; @@ -272,7 +272,8 @@ 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; @@ -289,7 +290,8 @@ 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; @@ -490,7 +492,8 @@ static int disk_read(void) { sstrncpy(disk_name, props_disk_name_bsd, sizeof(disk_name)); else { ERROR("disk plugin: can't find bsd disk name."); - ssnprintf(disk_name, sizeof(disk_name), "%i-%i", disk_major, disk_minor); + ssnprintf(disk_name, sizeof(disk_name), "%i-%i", disk_major, + disk_minor); } } else ssnprintf(disk_name, sizeof(disk_name), "%i-%i", disk_major, disk_minor); @@ -529,7 +532,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; @@ -893,7 +896,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 @@ -941,7 +944,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; @@ -968,7 +971,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/dpdkevents.c b/src/dpdkevents.c index a580a3a5..4c8196ae 100644 --- a/src/dpdkevents.c +++ b/src/dpdkevents.c @@ -512,7 +512,7 @@ static int dpdk_events_link_status_dispatch(dpdk_helper_ctx_t *phc) { char dev_name[DATA_MAX_NAME_LEN]; if (ec->config.link_status.port_name[i][0] != 0) { ssnprintf(dev_name, sizeof(dev_name), "%s", - ec->config.link_status.port_name[i]); + ec->config.link_status.port_name[i]); } else { ssnprintf(dev_name, sizeof(dev_name), "port.%d", i); } @@ -521,7 +521,7 @@ static int dpdk_events_link_status_dispatch(dpdk_helper_ctx_t *phc) { int sev = ec->link_info[i].link_status ? NOTIF_OKAY : NOTIF_WARNING; char msg[DATA_MAX_NAME_LEN]; ssnprintf(msg, sizeof(msg), "Link Status: %s", - ec->link_info[i].link_status ? "UP" : "DOWN"); + ec->link_info[i].link_status ? "UP" : "DOWN"); dpdk_events_notification_dispatch(sev, dev_name, ec->link_info[i].read_time, msg); } else { diff --git a/src/gmond.c b/src/gmond.c index 132c138d..1aaf86d1 100644 --- a/src/gmond.c +++ b/src/gmond.c @@ -398,7 +398,7 @@ static staging_entry_t *staging_entry_get(const char *host, /* {{{ */ return NULL; ssnprintf(key, sizeof(key), "%s/%s/%s", host, type, - (type_instance != NULL) ? type_instance : ""); + (type_instance != NULL) ? type_instance : ""); se = NULL; status = c_avl_get(staging_tree, key, (void *)&se); @@ -659,7 +659,9 @@ static int mc_handle_metadata_msg(Ganglia_metadata_msg *msg) /* {{{ */ break; } - default: { return -1; } + default: { + return -1; + } } return 0; diff --git a/src/intel_rdt.c b/src/intel_rdt.c index 8d5ce612..515a601e 100644 --- a/src/intel_rdt.c +++ b/src/intel_rdt.c @@ -145,7 +145,7 @@ static void rdt_dump_cgroups(void) { memset(cores, 0, sizeof(cores)); for (size_t j = 0; j < cgroup->num_cores; j++) { ssnprintf(cores + strlen(cores), sizeof(cores) - strlen(cores) - 1, " %d", - cgroup->cores[j]); + cgroup->cores[j]); } DEBUG(RDT_PLUGIN ": group[%zu]:", i); @@ -172,7 +172,7 @@ static void rdt_dump_ngroups(void) { memset(names, 0, sizeof(names)); for (size_t j = 0; j < g_rdt->ngroups[i].num_names; j++) ssnprintf(names + strlen(names), sizeof(names) - strlen(names) - 1, " %s", - g_rdt->ngroups[i].names[j]); + g_rdt->ngroups[i].names[j]); DEBUG(RDT_PLUGIN ": group[%d]:", (int)i); DEBUG(RDT_PLUGIN ": description: %s", g_rdt->ngroups[i].desc); @@ -250,7 +250,7 @@ static void rdt_dump_pids_data(void) { pids_list_t *list = g_rdt->ngroups[i].proc_pids[j]->curr; for (size_t k = 0; k < list->size; k++) ssnprintf(pids + strlen(pids), sizeof(pids) - strlen(pids) - 1, " %u", - list->pids[k]); + list->pids[k]); } DEBUG(RDT_PLUGIN ": [%s] %s", g_rdt->ngroups[i].desc, pids); } @@ -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 f17dbc4a..a18bcb44 100644 --- a/src/interface.c +++ b/src/interface.c @@ -82,7 +82,9 @@ 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); @@ -160,7 +162,8 @@ 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) @@ -188,7 +191,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 @@ -226,7 +229,7 @@ static int interface_read(void) { } freeifaddrs(if_list); -/* #endif HAVE_GETIFADDRS */ + /* #endif HAVE_GETIFADDRS */ #elif KERNEL_LINUX FILE *fh; @@ -282,7 +285,7 @@ static int interface_read(void) { } fclose(fh); -/* #endif KERNEL_LINUX */ + /* #endif KERNEL_LINUX */ #elif HAVE_LIBKSTAT derive_t rx; @@ -298,7 +301,7 @@ static int interface_read(void) { if (unique_name) ssnprintf(iname, sizeof(iname), "%s_%d_%s", ksp[i]->ks_module, - ksp[i]->ks_instance, ksp[i]->ks_name); + ksp[i]->ks_instance, ksp[i]->ks_name); else sstrncpy(iname, ksp[i]->ks_name, sizeof(iname)); @@ -332,7 +335,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; @@ -345,7 +348,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/ipmi.c b/src/ipmi.c index ed6c088e..db0e775f 100644 --- a/src/ipmi.c +++ b/src/ipmi.c @@ -202,7 +202,7 @@ static void sensor_read_handler(ipmi_sensor_t *sensor, int err, sizeof(n.type_instance)); sstrncpy(n.type, list_item->sensor_type, sizeof(n.type)); ssnprintf(n.message, sizeof(n.message), "sensor %s not present", - list_item->sensor_name); + list_item->sensor_name); plugin_dispatch_notification(&n); } @@ -255,7 +255,7 @@ static void sensor_read_handler(ipmi_sensor_t *sensor, int err, sizeof(n.type_instance)); sstrncpy(n.type, list_item->sensor_type, sizeof(n.type)); ssnprintf(n.message, sizeof(n.message), "sensor %s present", - list_item->sensor_name); + list_item->sensor_name); plugin_dispatch_notification(&n); } @@ -313,7 +313,8 @@ static void sensor_get_name(ipmi_sensor_t *sensor, char *buffer, int buf_len) { temp[sizeof(temp) - 1] = '\0'; if (entity_id_string != NULL && strlen(temp)) - ssnprintf(sensor_name, sizeof(sensor_name), "%s %s", temp, entity_id_string); + ssnprintf(sensor_name, sizeof(sensor_name), "%s %s", temp, + entity_id_string); else if (entity_id_string != NULL) sstrncpy(sensor_name, entity_id_string, sizeof(sensor_name)); else @@ -339,7 +340,7 @@ static void sensor_get_name(ipmi_sensor_t *sensor, char *buffer, int buf_len) { if (sensor_id_ptr != NULL) { /* `sensor_id_ptr' now points to "(123)". */ ssnprintf(sensor_name, sizeof(sensor_name), "%s %s", sensor_name_ptr, - sensor_id_ptr); + sensor_id_ptr); } /* else: don't touch sensor_name. */ } @@ -494,7 +495,7 @@ static int sensor_list_add(c_ipmi_instance_t *st, ipmi_sensor_t *sensor) { and add the `percent` to the type instance of the reported value */ if (ipmi_sensor_get_percentage(sensor)) { ssnprintf(list_item->type_instance, sizeof(list_item->type_instance), - "percent-%s", sensor_name_ptr); + "percent-%s", sensor_name_ptr); type = "percent"; } else { /* use type instance as a name of the sensor */ @@ -515,7 +516,7 @@ static int sensor_list_add(c_ipmi_instance_t *st, ipmi_sensor_t *sensor) { sizeof(n.type_instance)); sstrncpy(n.type, list_item->sensor_type, sizeof(n.type)); ssnprintf(n.message, sizeof(n.message), "sensor %s added", - list_item->sensor_name); + list_item->sensor_name); plugin_dispatch_notification(&n); } @@ -562,7 +563,7 @@ static int sensor_list_remove(c_ipmi_instance_t *st, ipmi_sensor_t *sensor) { sizeof(n.type_instance)); sstrncpy(n.type, list_item->sensor_type, sizeof(n.type)); ssnprintf(n.message, sizeof(n.message), "sensor %s removed", - list_item->sensor_name); + list_item->sensor_name); plugin_dispatch_notification(&n); } @@ -675,12 +676,12 @@ static int sensor_threshold_event_handler( sensor_get_name(sensor, n.type_instance, sizeof(n.type_instance)); if (value_present != IPMI_NO_VALUES_PRESENT) ssnprintf(n.message, sizeof(n.message), - "sensor %s received event: %s, value is %f", n.type_instance, - event_state, value); + "sensor %s received event: %s, value is %f", n.type_instance, + event_state, value); else ssnprintf(n.message, sizeof(n.message), - "sensor %s received event: %s, value not provided", - n.type_instance, event_state); + "sensor %s received event: %s, value not provided", + n.type_instance, event_state); DEBUG("Threshold event received for sensor %s", n.type_instance); @@ -742,7 +743,7 @@ static int sensor_discrete_event_handler(ipmi_sensor_t *sensor, ipmi_get_reading_name(event_type, sensor_type, offset); sensor_get_name(sensor, n.type_instance, sizeof(n.type_instance)); ssnprintf(n.message, sizeof(n.message), "sensor %s received event: %s", - n.type_instance, event_state); + n.type_instance, event_state); DEBUG("Discrete event received for sensor %s", n.type_instance); diff --git a/src/iptables.c b/src/iptables.c index 8bc71ccb..ea2d2404 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -222,7 +222,7 @@ static int submit6_match(const struct ip6t_entry_match *match, sstrncpy(vl.plugin, "ip6tables", sizeof(vl.plugin)); status = ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%s", - chain->table, chain->chain); + chain->table, chain->chain); if ((status < 1) || ((unsigned int)status >= sizeof(vl.plugin_instance))) return 0; @@ -231,7 +231,7 @@ static int submit6_match(const struct ip6t_entry_match *match, } else { if (chain->rule_type == RTYPE_NUM) ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%i", - chain->rule.num); + chain->rule.num); else sstrncpy(vl.type_instance, (char *)match->data, sizeof(vl.type_instance)); } @@ -270,7 +270,7 @@ static int submit_match(const struct ipt_entry_match *match, sstrncpy(vl.plugin, "iptables", sizeof(vl.plugin)); status = ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%s", - chain->table, chain->chain); + chain->table, chain->chain); if ((status < 1) || ((unsigned int)status >= sizeof(vl.plugin_instance))) return 0; @@ -279,7 +279,7 @@ static int submit_match(const struct ipt_entry_match *match, } else { if (chain->rule_type == RTYPE_NUM) ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%i", - chain->rule.num); + chain->rule.num); else sstrncpy(vl.type_instance, (char *)match->data, sizeof(vl.type_instance)); } diff --git a/src/lua.c b/src/lua.c index bcefafc1..3f48a55d 100644 --- a/src/lua.c +++ b/src/lua.c @@ -299,7 +299,7 @@ static int lua_cb_register_generic(lua_State *L, int type) /* {{{ */ lua_getfield(L, LUA_REGISTRYINDEX, "collectd:script_path"); char function_name[DATA_MAX_NAME_LEN]; ssnprintf(function_name, sizeof(function_name), "lua/%s/%s", - lua_tostring(L, -1), subname); + lua_tostring(L, -1), subname); lua_pop(L, 1); int callback_id = clua_store_callback(L, 1); @@ -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,7 +338,8 @@ 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/lvm.c b/src/lvm.c index 6163ff83..3077c93c 100644 --- a/src/lvm.c +++ b/src/lvm.c @@ -81,7 +81,8 @@ static void report_lv_utilization(lv_t lv, char const *vg_name, return; used_bytes = lv_size * (used_percent_unscaled * PERCENT_SCALE_FACTOR); - ssnprintf(plugin_instance, sizeof(plugin_instance), "%s-%s", vg_name, lv_name); + ssnprintf(plugin_instance, sizeof(plugin_instance), "%s-%s", vg_name, + lv_name); lvm_submit(plugin_instance, "used", used_bytes); lvm_submit(plugin_instance, "free", lv_size - used_bytes); } diff --git a/src/mic.c b/src/mic.c index 70765574..584d2e2b 100644 --- a/src/mic.c +++ b/src/mic.c @@ -209,7 +209,7 @@ static void mic_submit_cpu(int micnumber, const char *type_instance, int core, ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%i", micnumber); else /* per-core statistics */ ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%i-cpu-%i", - micnumber, core); + micnumber, core); strncpy(vl.type, "cpu", sizeof(vl.type)); strncpy(vl.type_instance, type_instance, sizeof(vl.type_instance)); diff --git a/src/modbus.c b/src/modbus.c index 5b2509b4..b551facd 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -1078,7 +1078,8 @@ 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 23e62c41..aafd4dbd 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -225,7 +225,8 @@ 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); @@ -354,7 +355,8 @@ 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); @@ -501,14 +503,14 @@ static int mysql_read_slave_stats(mysql_database_t *db, MYSQL *con) { (db->slave_io_running)) { n.severity = NOTIF_WARNING; ssnprintf(n.message, sizeof(n.message), - "slave I/O thread not started or not connected to master"); + "slave I/O thread not started or not connected to master"); plugin_dispatch_notification(&n); db->slave_io_running = false; } else if (((io != NULL) && (strcasecmp(io, "yes") == 0)) && (!db->slave_io_running)) { n.severity = NOTIF_OKAY; ssnprintf(n.message, sizeof(n.message), - "slave I/O thread started and connected to master"); + "slave I/O thread started and connected to master"); plugin_dispatch_notification(&n); db->slave_io_running = true; } diff --git a/src/netapp.c b/src/netapp.c index b950acc4..43aaa7a7 100644 --- a/src/netapp.c +++ b/src/netapp.c @@ -643,7 +643,8 @@ 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, @@ -666,7 +667,8 @@ 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, @@ -774,13 +776,12 @@ static int submit_volume_perf_data(const char *hostname, /* {{{ */ return -1; ssnprintf(plugin_instance, sizeof(plugin_instance), "volume-%s", - old_data->name); + old_data->name); /* 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, @@ -798,15 +799,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; @@ -1406,9 +1407,8 @@ 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,9 +1422,8 @@ 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 { @@ -1466,9 +1465,8 @@ 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); @@ -1498,12 +1496,13 @@ static int cna_change_volume_status(const char *hostname, /* {{{ */ if ((v->flags & IS_VOLUME_USAGE_OFFLINE) != 0) { n.severity = NOTIF_OKAY; - ssnprintf(n.message, sizeof(n.message), "Volume %s is now online.", v->name); + ssnprintf(n.message, sizeof(n.message), "Volume %s is now online.", + v->name); v->flags &= ~IS_VOLUME_USAGE_OFFLINE; } else { n.severity = NOTIF_WARNING; ssnprintf(n.message, sizeof(n.message), "Volume %s is now offline.", - v->name); + v->name); v->flags |= IS_VOLUME_USAGE_OFFLINE; } @@ -1833,7 +1832,7 @@ static int cna_handle_quota_data(const host_config_t *host, /* {{{ */ continue; ssnprintf(plugin_instance, sizeof(plugin_instance), "quota-%s-%s", - volume_name, tree_name); + volume_name, tree_name); value = na_child_get_uint64(elem_quota, "disk-used", UINT64_MAX); if (value != UINT64_MAX) { @@ -1946,7 +1945,7 @@ static int cna_handle_snapvault_data(const char *hostname, /* {{{ */ /* possible TODO: make plugin instance configurable */ ssnprintf(plugin_instance, sizeof(plugin_instance), "snapvault-%s", - dest_path); + dest_path); submit_double(hostname, plugin_instance, /* type = */ "delay", NULL, (double)value, /* timestamp = */ 0, interval); @@ -2788,7 +2787,7 @@ static int cna_register_host(host_config_t *host) /* {{{ */ if (host->vfiler) ssnprintf(cb_name, sizeof(cb_name), "netapp-%s-%s", host->name, - host->vfiler); + host->vfiler); else ssnprintf(cb_name, sizeof(cb_name), "netapp-%s", host->name); @@ -2797,7 +2796,8 @@ 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 a3b40d49..806265a2 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -198,7 +198,8 @@ 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; @@ -510,7 +511,7 @@ static int qos_filter_cb(const struct nlmsghdr *nlh, void *args) { numberic_id = tm->tcm_parent; ssnprintf(tc_inst, sizeof(tc_inst), "%s-%x:%x", kind, numberic_id >> 16, - numberic_id & 0x0000FFFF); + numberic_id & 0x0000FFFF); } DEBUG("netlink plugin: qos_filter_cb: got %s for %s (%i).", tc_type, dev, @@ -542,7 +543,7 @@ static int qos_filter_cb(const struct nlmsghdr *nlh, void *args) { stats_submitted = true; int r = ssnprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type, - tc_inst); + tc_inst); if ((size_t)r >= sizeof(type_instance)) { ERROR("netlink plugin: type_instance truncated to %zu bytes, need %d", sizeof(type_instance), r); @@ -581,7 +582,7 @@ static int qos_filter_cb(const struct nlmsghdr *nlh, void *args) { char type_instance[DATA_MAX_NAME_LEN]; int r = ssnprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type, - tc_inst); + tc_inst); if ((size_t)r >= sizeof(type_instance)) { ERROR("netlink plugin: type_instance truncated to %zu bytes, need %d", sizeof(type_instance), r); diff --git a/src/nginx.c b/src/nginx.c index 15e56fbc..0da66ce2 100644 --- a/src/nginx.c +++ b/src/nginx.c @@ -123,7 +123,7 @@ static int init(void) { #else static char credentials[1024]; int status = ssnprintf(credentials, sizeof(credentials), "%s:%s", user, - pass == NULL ? "" : pass); + pass == NULL ? "" : pass); if ((status < 0) || ((size_t)status >= sizeof(credentials))) { ERROR("nginx plugin: Credentials would have been truncated."); return -1; diff --git a/src/notify_desktop.c b/src/notify_desktop.c index 520a2804..e430b681 100644 --- a/src/notify_desktop.c +++ b/src/notify_desktop.c @@ -94,15 +94,15 @@ static int c_notify(const notification_t *n, } ssnprintf(summary, sizeof(summary), "collectd %s notification", - (NOTIF_FAILURE == n->severity) - ? "FAILURE" - : (NOTIF_WARNING == n->severity) - ? "WARNING" - : (NOTIF_OKAY == n->severity) ? "OKAY" : "UNKNOWN"); + (NOTIF_FAILURE == n->severity) + ? "FAILURE" + : (NOTIF_WARNING == n->severity) + ? "WARNING" + : (NOTIF_OKAY == n->severity) ? "OKAY" : "UNKNOWN"); notification = notify_notification_new(summary, n->message, NULL #if NOTIFY_CHECK_VERSION(0, 7, 0) - ); + ); #else , NULL); diff --git a/src/notify_email.c b/src/notify_email.c index e620cf63..0e140e4e 100644 --- a/src/notify_email.c +++ b/src/notify_email.c @@ -105,7 +105,7 @@ static int notify_email_init(void) { char server[MAXSTRING]; ssnprintf(server, sizeof(server), "%s:%i", - (smtp_host == NULL) ? DEFAULT_SMTP_HOST : smtp_host, smtp_port); + (smtp_host == NULL) ? DEFAULT_SMTP_HOST : smtp_host, smtp_port); pthread_mutex_lock(&session_lock); @@ -215,15 +215,15 @@ static int notify_email_notification(const notification_t *n, int buf_len = sizeof(buf); ssnprintf(severity, sizeof(severity), "%s", - (n->severity == NOTIF_FAILURE) - ? "FAILURE" - : ((n->severity == NOTIF_WARNING) - ? "WARNING" - : ((n->severity == NOTIF_OKAY) ? "OKAY" : "UNKNOWN"))); + (n->severity == NOTIF_FAILURE) + ? "FAILURE" + : ((n->severity == NOTIF_WARNING) + ? "WARNING" + : ((n->severity == NOTIF_OKAY) ? "OKAY" : "UNKNOWN"))); ssnprintf(subject, sizeof(subject), - (email_subject == NULL) ? DEFAULT_SMTP_SUBJECT : email_subject, - severity, n->host); + (email_subject == NULL) ? DEFAULT_SMTP_SUBJECT : email_subject, + severity, n->host); localtime_r(&CDTIME_T_TO_TIME_T(n->time), ×tamp_tm); strftime(timestamp_str, sizeof(timestamp_str), "%Y-%m-%d %H:%M:%S", @@ -232,14 +232,14 @@ static int notify_email_notification(const notification_t *n, /* Let's make RFC822 message text with \r\n EOLs */ int status = ssnprintf(buf, buf_len, - "MIME-Version: 1.0\r\n" - "Content-Type: text/plain; charset=\"US-ASCII\"\r\n" - "Content-Transfer-Encoding: 8bit\r\n" - "Subject: %s\r\n" - "\r\n" - "%s - %s@%s\r\n" - "\r\n", - subject, timestamp_str, severity, n->host); + "MIME-Version: 1.0\r\n" + "Content-Type: text/plain; charset=\"US-ASCII\"\r\n" + "Content-Transfer-Encoding: 8bit\r\n" + "Subject: %s\r\n" + "\r\n" + "%s - %s@%s\r\n" + "\r\n", + subject, timestamp_str, severity, n->host); if (status > 0) { buf_ptr += status; @@ -248,7 +248,7 @@ static int notify_email_notification(const notification_t *n, #define APPEND(format, value) \ if ((buf_len > 0) && (strlen(value) > 0)) { \ - status = ssnprintf(buf_ptr, buf_len, format "\r\n", value); \ + status = ssnprintf(buf_ptr, buf_len, format "\r\n", value); \ if (status > 0) { \ buf_ptr += status; \ buf_len -= status; \ diff --git a/src/onewire.c b/src/onewire.c index 7153b0ad..729a05c7 100644 --- a/src/onewire.c +++ b/src/onewire.c @@ -298,7 +298,7 @@ static int cow_read_values(const char *path, const char *name, char *endptr; ssnprintf(file, sizeof(file), "%s/%s", path, - family_info->features[i].filename); + family_info->features[i].filename); file[sizeof(file) - 1] = '\0'; buffer = NULL; diff --git a/src/openldap.c b/src/openldap.c index 7dc8f739..cd72cdbe 100644 --- a/src/openldap.c +++ b/src/openldap.c @@ -307,7 +307,7 @@ static int cldap_read_host(user_data_t *ud) /* {{{ */ ldap_get_values_len(st->ld, e, "olmBDBEntryCache")) != NULL) { olmbdb_data = *olmbdb_list[0]; ssnprintf(typeinst, sizeof(typeinst), "bdbentrycache-%s", - nc_data.bv_val); + nc_data.bv_val); cldap_submit_gauge("cache_size", typeinst, atoll(olmbdb_data.bv_val), st); ldap_value_free_len(olmbdb_list); @@ -316,7 +316,8 @@ static int cldap_read_host(user_data_t *ud) /* {{{ */ if ((olmbdb_list = ldap_get_values_len(st->ld, e, "olmBDBDNCache")) != NULL) { olmbdb_data = *olmbdb_list[0]; - ssnprintf(typeinst, sizeof(typeinst), "bdbdncache-%s", nc_data.bv_val); + ssnprintf(typeinst, sizeof(typeinst), "bdbdncache-%s", + nc_data.bv_val); cldap_submit_gauge("cache_size", typeinst, atoll(olmbdb_data.bv_val), st); ldap_value_free_len(olmbdb_list); @@ -326,7 +327,7 @@ static int cldap_read_host(user_data_t *ud) /* {{{ */ NULL) { olmbdb_data = *olmbdb_list[0]; ssnprintf(typeinst, sizeof(typeinst), "bdbidlcache-%s", - nc_data.bv_val); + nc_data.bv_val); cldap_submit_gauge("cache_size", typeinst, atoll(olmbdb_data.bv_val), st); ldap_value_free_len(olmbdb_list); @@ -463,15 +464,16 @@ static int cldap_config_add(oconfig_item_t *ci) /* {{{ */ char callback_name[3 * DATA_MAX_NAME_LEN] = {0}; ssnprintf(callback_name, sizeof(callback_name), "openldap/%s/%s", - (st->host != NULL) ? st->host : hostname_g, - (st->name != NULL) ? st->name : "default"); + (st->host != NULL) ? st->host : hostname_g, + (st->name != NULL) ? st->name : "default"); return plugin_register_complex_read(/* group = */ NULL, /* name = */ callback_name, /* 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_events.c b/src/ovs_events.c index 49e08f58..ae8ac3db 100644 --- a/src/ovs_events.c +++ b/src/ovs_events.c @@ -159,7 +159,7 @@ static char *ovs_events_get_select_params() { } opt_buff = new_buff; int ret = ssnprintf(opt_buff + buff_off, buff_size - buff_off, option_fmt, - iface->name); + iface->name); if (ret < 0) { sfree(opt_buff); return NULL; @@ -340,8 +340,8 @@ ovs_events_dispatch_notification(const ovs_events_iface_info_t *ifinfo) { /* fill the notification data */ ssnprintf(n.message, sizeof(n.message), - "link state of \"%s\" interface has been changed to \"%s\"", - ifinfo->name, msg_link_status); + "link state of \"%s\" interface has been changed to \"%s\"", + ifinfo->name, msg_link_status); sstrncpy(n.host, hostname_g, sizeof(n.host)); sstrncpy(n.plugin_instance, ifinfo->name, sizeof(n.plugin_instance)); sstrncpy(n.type, "gauge", sizeof(n.type)); diff --git a/src/ovs_stats.c b/src/ovs_stats.c index 4ec14f4f..e22e851e 100644 --- a/src/ovs_stats.c +++ b/src/ovs_stats.c @@ -282,7 +282,9 @@ 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/postgresql.c b/src/postgresql.c index 466c0e3a..4e608be1 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -58,7 +58,7 @@ * is ignored. */ #define C_PSQL_PAR_APPEND(buf, buf_len, parameter, value) \ if ((0 < (buf_len)) && (NULL != (value)) && ('\0' != *(value))) { \ - int s = ssnprintf(buf, buf_len, " %s = '%s'", parameter, value); \ + int s = ssnprintf(buf, buf_len, " %s = '%s'", parameter, value); \ if (0 < s) { \ buf += s; \ buf_len -= s; \ @@ -427,7 +427,7 @@ static PGresult *c_psql_exec_query_params(c_psql_database_t *db, udb_query_t *q, break; case C_PSQL_PARAM_INTERVAL: ssnprintf(interval, sizeof(interval), "%.3f", - CDTIME_T_TO_DOUBLE(plugin_get_interval())); + CDTIME_T_TO_DOUBLE(plugin_get_interval())); params[i] = interval; break; case C_PSQL_PARAM_INSTANCE: @@ -673,7 +673,7 @@ static char *values_type_to_sqlarray(const data_set_t *ds, char *string, status = ssnprintf(str_ptr, str_len, ",'gauge'"); else status = ssnprintf(str_ptr, str_len, ",'%s'", - DS_TYPE_TO_STRING(ds->ds[i].type)); + DS_TYPE_TO_STRING(ds->ds[i].type)); if (status < 1) { str_len = 0; @@ -738,7 +738,7 @@ static char *values_to_sqlarray(const data_set_t *ds, const value_list_t *vl, status = ssnprintf(str_ptr, str_len, ",%lf", rates[i]); } else if (ds->ds[i].type == DS_TYPE_COUNTER) status = ssnprintf(str_ptr, str_len, ",%" PRIu64, - (uint64_t)vl->values[i].counter); + (uint64_t)vl->values[i].counter); else if (ds->ds[i].type == DS_TYPE_DERIVE) status = ssnprintf(str_ptr, str_len, ",%" PRIi64, vl->values[i].derive); else if (ds->ds[i].type == DS_TYPE_ABSOLUTE) diff --git a/src/protocols.c b/src/protocols.c index 86fa795a..7bfa663c 100644 --- a/src/protocols.c +++ b/src/protocols.c @@ -41,7 +41,8 @@ * Global variables */ static const char *config_keys[] = { - "Value", "IgnoreSelected", + "Value", + "IgnoreSelected", }; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); @@ -155,7 +156,7 @@ static int read_file(const char *path) { char match_name[2 * DATA_MAX_NAME_LEN]; ssnprintf(match_name, sizeof(match_name), "%s:%s", key_buffer, - key_fields[i]); + key_fields[i]); if (ignorelist_match(values_list, match_name)) continue; diff --git a/src/python.c b/src/python.c index 5669f45a..70db6b6f 100644 --- a/src/python.c +++ b/src/python.c @@ -703,8 +703,9 @@ 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); @@ -774,7 +775,8 @@ 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; @@ -817,7 +819,8 @@ 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); @@ -1201,8 +1204,9 @@ 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 12f68946..77ce5fb6 100644 --- a/src/redis.c +++ b/src/redis.c @@ -123,7 +123,8 @@ 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 a0956377..ece865b6 100644 --- a/src/routeros.c +++ b/src/routeros.c @@ -53,7 +53,8 @@ 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; @@ -151,7 +152,7 @@ static void submit_regtable(cr_data_t *rd, /* {{{ */ /*** RX ***/ ssnprintf(type_instance, sizeof(type_instance), "%s-%s-rx", r->interface, - name); + name); cr_submit_gauge(rd, "bitrate", type_instance, (gauge_t)(1000000.0 * r->rx_rate)); cr_submit_gauge(rd, "signal_power", type_instance, @@ -160,7 +161,7 @@ static void submit_regtable(cr_data_t *rd, /* {{{ */ /*** TX ***/ ssnprintf(type_instance, sizeof(type_instance), "%s-%s-tx", r->interface, - name); + name); cr_submit_gauge(rd, "bitrate", type_instance, (gauge_t)(1000000.0 * r->tx_rate)); cr_submit_gauge(rd, "signal_power", type_instance, @@ -442,7 +443,8 @@ 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 4623d785..1e75ff83 100644 --- a/src/rrdcached.c +++ b/src/rrdcached.c @@ -81,16 +81,16 @@ static int value_list_to_string(char *buffer, int buffer_len, if (ds->ds[i].type == DS_TYPE_COUNTER) { status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIu64, - (uint64_t)vl->values[i].counter); + (uint64_t)vl->values[i].counter); } else if (ds->ds[i].type == DS_TYPE_GAUGE) { status = ssnprintf(buffer + offset, buffer_len - offset, ":%f", - vl->values[i].gauge); + vl->values[i].gauge); } else if (ds->ds[i].type == DS_TYPE_DERIVE) { status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIi64, - vl->values[i].derive); + vl->values[i].derive); } else /* if (ds->ds[i].type == DS_TYPE_ABSOLUTE) */ { status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIu64, - vl->values[i].absolute); + vl->values[i].absolute); } if ((status < 1) || (status >= (buffer_len - offset))) @@ -426,7 +426,8 @@ 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/rrdtool.c b/src/rrdtool.c index fc659925..f30bc267 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -187,16 +187,16 @@ static int value_list_to_string_multiple(char *buffer, int buffer_len, if (ds->ds[i].type == DS_TYPE_COUNTER) status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIu64, - (uint64_t)vl->values[i].counter); + (uint64_t)vl->values[i].counter); else if (ds->ds[i].type == DS_TYPE_GAUGE) status = ssnprintf(buffer + offset, buffer_len - offset, ":" GAUGE_FORMAT, - vl->values[i].gauge); + vl->values[i].gauge); else if (ds->ds[i].type == DS_TYPE_DERIVE) status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIi64, - vl->values[i].derive); + vl->values[i].derive); else /*if (ds->ds[i].type == DS_TYPE_ABSOLUTE) */ status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIu64, - vl->values[i].absolute); + vl->values[i].absolute); if ((status < 1) || (status >= (buffer_len - offset))) return -1; @@ -219,19 +219,19 @@ static int value_list_to_string(char *buffer, int buffer_len, switch (ds->ds[0].type) { case DS_TYPE_DERIVE: status = ssnprintf(buffer, buffer_len, "%u:%" PRIi64, (unsigned)tt, - vl->values[0].derive); + vl->values[0].derive); break; case DS_TYPE_GAUGE: status = ssnprintf(buffer, buffer_len, "%u:" GAUGE_FORMAT, (unsigned)tt, - vl->values[0].gauge); + vl->values[0].gauge); break; case DS_TYPE_COUNTER: status = ssnprintf(buffer, buffer_len, "%u:%" PRIu64, (unsigned)tt, - (uint64_t)vl->values[0].counter); + (uint64_t)vl->values[0].counter); break; case DS_TYPE_ABSOLUTE: status = ssnprintf(buffer, buffer_len, "%u:%" PRIu64, (unsigned)tt, - vl->values[0].absolute); + vl->values[0].absolute); break; default: return EINVAL; diff --git a/src/sigrok.c b/src/sigrok.c index 78d1f1db..07bd1c81 100644 --- a/src/sigrok.c +++ b/src/sigrok.c @@ -248,9 +248,9 @@ static int sigrok_init_driver(struct config_device *cfdev, cfdev->sdi = devlist->data; g_slist_free(devlist); ssnprintf(hwident, sizeof(hwident), "%s %s %s", - cfdev->sdi->vendor ? cfdev->sdi->vendor : "", - cfdev->sdi->model ? cfdev->sdi->model : "", - cfdev->sdi->version ? cfdev->sdi->version : ""); + cfdev->sdi->vendor ? cfdev->sdi->vendor : "", + cfdev->sdi->model ? cfdev->sdi->model : "", + cfdev->sdi->version ? cfdev->sdi->version : ""); INFO("sigrok plugin: Device \"%s\" is a %s", cfdev->name, hwident); if (sr_dev_open(cfdev->sdi) != SR_OK) diff --git a/src/smart.c b/src/smart.c index 85ebf0af..627c16d5 100644 --- a/src/smart.c +++ b/src/smart.c @@ -117,8 +117,8 @@ static void handle_attribute(SkDisk *d, const SkSmartAttributeParsedData *a, sstrncpy(notif.plugin_instance, name, sizeof(notif.plugin_instance)); sstrncpy(notif.type_instance, a->name, sizeof(notif.type_instance)); ssnprintf(notif.message, sizeof(notif.message), - "attribute %s is below allowed threshold (%d < %d)", a->name, - a->current_value, a->threshold); + "attribute %s is below allowed threshold (%d < %d)", a->name, + a->current_value, a->threshold); plugin_dispatch_notification(¬if); } } diff --git a/src/snmp.c b/src/snmp.c index e0ca7ff6..aeb04fdd 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -876,7 +876,8 @@ 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."); @@ -1141,7 +1142,7 @@ static int csnmp_strvbcopy_hexstring(char *dst, /* {{{ */ int status; status = ssnprintf(buffer_ptr, buffer_free, (i == 0) ? "%02x" : ":%02x", - (unsigned int)vb->val.bitstring[i]); + (unsigned int)vb->val.bitstring[i]); assert(status >= 0); if (((size_t)status) >= buffer_free) /* truncated */ @@ -1174,9 +1175,9 @@ static int csnmp_strvbcopy(char *dst, /* {{{ */ src = (char *)vb->val.bitstring; else if (vb->type == ASN_IPADDRESS) { return ssnprintf(dst, dst_size, - "%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8 "", - (uint8_t)vb->val.string[0], (uint8_t)vb->val.string[1], - (uint8_t)vb->val.string[2], (uint8_t)vb->val.string[3]); + "%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8 "", + (uint8_t)vb->val.string[0], (uint8_t)vb->val.string[1], + (uint8_t)vb->val.string[2], (uint8_t)vb->val.string[3]); } else { dst[0] = 0; return EINVAL; @@ -1496,7 +1497,7 @@ static int csnmp_dispatch_table(host_definition_t *host, sstrncpy(vl.type_instance, temp, sizeof(vl.type_instance)); else ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%s%s", - data->type_instance.prefix, temp); + data->type_instance.prefix, temp); } else if (data->type_instance.value) { sstrncpy(vl.type_instance, data->type_instance.value, sizeof(vl.type_instance)); @@ -1514,7 +1515,7 @@ static int csnmp_dispatch_table(host_definition_t *host, sstrncpy(vl.plugin_instance, temp, sizeof(vl.plugin_instance)); else ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s%s", - data->plugin_instance.prefix, temp); + data->plugin_instance.prefix, temp); } else if (data->plugin_instance.value) { sstrncpy(vl.plugin_instance, data->plugin_instance.value, sizeof(vl.plugin_instance)); diff --git a/src/snmp_agent.c b/src/snmp_agent.c index 97eae7c0..bb4a7e42 100644 --- a/src/snmp_agent.c +++ b/src/snmp_agent.c @@ -742,7 +742,8 @@ static void snmp_agent_table_data_remove(data_definition_t *dd, .severity = NOTIF_WARNING, .time = cdtime(), .plugin = PLUGIN_NAME}; sstrncpy(n.host, hostname_g, sizeof(n.host)); ssnprintf(n.message, sizeof(n.message), - "Removed data row from table %s with index %s", td->name, index_str); + "Removed data row from table %s with index %s", td->name, + index_str); DEBUG(PLUGIN_NAME ": %s", n.message); plugin_dispatch_notification(&n); @@ -2001,7 +2002,7 @@ static int snmp_agent_update_index(data_definition_t *dd, .severity = NOTIF_OKAY, .time = cdtime(), .plugin = PLUGIN_NAME}; sstrncpy(n.host, hostname_g, sizeof(n.host)); ssnprintf(n.message, sizeof(n.message), - "Data added to table %s with index %s", td->name, index_str); + "Data added to table %s with index %s", td->name, index_str); DEBUG(PLUGIN_NAME ": %s", n.message); plugin_dispatch_notification(&n); diff --git a/src/threshold.c b/src/threshold.c index 93ca5fdb..e74dfc2c 100644 --- a/src/threshold.c +++ b/src/threshold.c @@ -367,9 +367,10 @@ 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.", - ds->ds[ds_index].name, values[ds_index]); + 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 " "state. This shouldn't happen."); @@ -384,20 +385,21 @@ static int ut_report_state(const data_set_t *ds, const value_list_t *vl, if (th->flags & UT_FLAG_INVERT) { if (!isnan(min) && !isnan(max)) { ssnprintf(buf, bufsize, - ": Data source \"%s\" is currently " - "%f. That is within the %s region of %f%s and %f%s.", - ds->ds[ds_index].name, values[ds_index], - (state == STATE_ERROR) ? "failure" : "warning", min, - ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "", max, - ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : ""); + ": Data source \"%s\" is currently " + "%f. That is within the %s region of %f%s and %f%s.", + ds->ds[ds_index].name, values[ds_index], + (state == STATE_ERROR) ? "failure" : "warning", min, + ((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.", - ds->ds[ds_index].name, values[ds_index], - isnan(min) ? "below" : "above", - (state == STATE_ERROR) ? "failure" : "warning", - isnan(min) ? max : min, - ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : ""); + 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", + isnan(min) ? max : min, + ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : ""); } } else if (th->flags & UT_FLAG_PERCENTAGE) { gauge_t value; @@ -417,20 +419,21 @@ static int ut_report_state(const data_set_t *ds, const value_list_t *vl, value = 100.0 * values[ds_index] / sum; ssnprintf(buf, bufsize, - ": Data source \"%s\" is currently " - "%g (%.2f%%). That is %s the %s threshold of %.2f%%.", - ds->ds[ds_index].name, values[ds_index], value, - (value < min) ? "below" : "above", - (state == STATE_ERROR) ? "failure" : "warning", - (value < min) ? min : max); + ": Data source \"%s\" is currently " + "%g (%.2f%%). That is %s the %s threshold of %.2f%%.", + ds->ds[ds_index].name, values[ds_index], value, + (value < min) ? "below" : "above", + (state == STATE_ERROR) ? "failure" : "warning", + (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.", - ds->ds[ds_index].name, values[ds_index], - (values[ds_index] < min) ? "below" : "above", - (state == STATE_ERROR) ? "failure" : "warning", - (values[ds_index] < min) ? min : max); + 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", + (values[ds_index] < min) ? min : max); } } @@ -690,8 +693,8 @@ static int ut_missing(const value_list_t *vl, NOTIFICATION_INIT_VL(&n, vl); ssnprintf(n.message, sizeof(n.message), - "%s has not been updated for %.3f seconds.", identifier, - CDTIME_T_TO_DOUBLE(missing_time)); + "%s has not been updated for %.3f seconds.", identifier, + CDTIME_T_TO_DOUBLE(missing_time)); n.time = now; plugin_dispatch_notification(&n); diff --git a/src/utils/cmds/cmds_test.c b/src/utils/cmds/cmds_test.c index 3100e81f..edbf5c95 100644 --- a/src/utils/cmds/cmds_test.c +++ b/src/utils/cmds/cmds_test.c @@ -295,13 +295,14 @@ 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])", - 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, - CMD_TO_STRING(parse_data[i].expected_type)); + 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, + CMD_TO_STRING(parse_data[i].expected_type)); result = (status == parse_data[i].expected_status) && (cmd.type == parse_data[i].expected_type); LOG(result, description); diff --git a/src/utils/common/common.c b/src/utils/common/common.c index e986da81..0d2aaae6 100644 --- a/src/utils/common/common.c +++ b/src/utils/common/common.c @@ -25,7 +25,7 @@ * Niki W. Waibel * Sebastian Harl * Michał Mirosław -**/ + **/ #include "collectd.h" @@ -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,17 +191,19 @@ 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 */ @@ -737,9 +739,8 @@ long long get_kstat_value(kstat_t *ksp, char *name) { else if (kn->data_type == KSTAT_DATA_UINT32) retval = (long long)kn->value.ui32; else if (kn->data_type == KSTAT_DATA_INT64) - retval = - (long long)kn->value.i64; /* According to ANSI C99 `long long' must hold - at least 64 bits */ + retval = (long long)kn->value.i64; /* According to ANSI C99 `long long' must + hold at least 64 bits */ else if (kn->data_type == KSTAT_DATA_UINT64) retval = (long long)kn->value.ui64; /* XXX: Might overflow! */ else diff --git a/src/utils/common/common.h b/src/utils/common/common.h index 480d0e90..1ca65054 100644 --- a/src/utils/common/common.h +++ b/src/utils/common/common.h @@ -23,7 +23,7 @@ * Authors: * Florian octo Forster * Niki W. Waibel -**/ + **/ #ifndef COMMON_H #define COMMON_H diff --git a/src/utils/db_query/db_query.c b/src/utils/db_query/db_query.c index 2c5eab3f..fa43fe56 100644 --- a/src/utils/db_query/db_query.c +++ b/src/utils/db_query/db_query.c @@ -229,7 +229,7 @@ static int udb_result_submit(udb_result_t *r, /* {{{ */ tmp[sizeof(tmp) - 1] = '\0'; ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%s-%s", - r->instance_prefix, tmp); + r->instance_prefix, tmp); } } vl.type_instance[sizeof(vl.type_instance) - 1] = '\0'; diff --git a/src/utils/dpdk/dpdk.c b/src/utils/dpdk/dpdk.c index 4d05424b..7d9f7abc 100644 --- a/src/utils/dpdk/dpdk.c +++ b/src/utils/dpdk/dpdk.c @@ -113,7 +113,7 @@ static void dpdk_helper_config_default(dpdk_helper_ctx_t *phc) { ssnprintf(phc->eal_config.coremask, DATA_MAX_NAME_LEN, "%s", "0xf"); ssnprintf(phc->eal_config.memory_channels, DATA_MAX_NAME_LEN, "%s", "1"); ssnprintf(phc->eal_config.file_prefix, DATA_MAX_NAME_LEN, "%s", - DPDK_DEFAULT_RTE_CONFIG); + DPDK_DEFAULT_RTE_CONFIG); } int dpdk_helper_eal_config_set(dpdk_helper_ctx_t *phc, dpdk_eal_config_t *ec) { @@ -190,10 +190,10 @@ int dpdk_helper_eal_config_parse(dpdk_helper_ctx_t *phc, oconfig_item_t *ci) { if (status == 0) { #if RTE_VERSION <= RTE_VERSION_NUM(18, 5, 0, 0) ssnprintf(phc->eal_config.file_prefix, DATA_MAX_NAME_LEN, - "/var/run/.%s_config", prefix); + "/var/run/.%s_config", prefix); #else ssnprintf(phc->eal_config.file_prefix, DATA_MAX_NAME_LEN, - "/var/run/dpdk/%s/config", prefix); + "/var/run/dpdk/%s/config", prefix); #endif DEBUG("dpdk_common: EAL:File prefix %s", phc->eal_config.file_prefix); } @@ -304,8 +304,8 @@ int dpdk_helper_init(const char *name, size_t data_size, DPDK_HELPER_TRACE(name); /* Allocate dpdk_helper_ctx_t and - * initialize a POSIX SHared Memory (SHM) object. - */ + * initialize a POSIX SHared Memory (SHM) object. + */ int err = dpdk_shm_init(name, shm_size, (void **)&phc); if (err != 0) { return -errno; @@ -704,7 +704,8 @@ 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/format_stackdriver/format_stackdriver.c b/src/utils/format_stackdriver/format_stackdriver.c index 9b8b5474..ccb1c77d 100644 --- a/src/utils/format_stackdriver/format_stackdriver.c +++ b/src/utils/format_stackdriver/format_stackdriver.c @@ -177,7 +177,7 @@ static int format_typed_value(yajl_gen gen, int ds_type, value_t v, * "CUMULATIVE", * "GAUGE" * ) -*/ + */ static int format_metric_kind(yajl_gen gen, int ds_type) { switch (ds_type) { case DS_TYPE_GAUGE: @@ -198,7 +198,7 @@ static int format_metric_kind(yajl_gen gen, int ds_type) { * "DOUBLE", * "INT64" * ) -*/ + */ static int format_value_type(yajl_gen gen, int ds_type) { return json_string(gen, (ds_type == DS_TYPE_GAUGE) ? "DOUBLE" : "INT64"); } @@ -211,7 +211,7 @@ static int metric_type(char *buffer, size_t buffer_size, data_set_t const *ds, #define GCM_PREFIX "custom.googleapis.com/collectd/" if ((ds_index != 0) || strcmp("value", ds_name) != 0) { ssnprintf(buffer, buffer_size, GCM_PREFIX "%s/%s_%s", vl->plugin, vl->type, - ds_name); + ds_name); } else { ssnprintf(buffer, buffer_size, GCM_PREFIX "%s/%s", vl->plugin, vl->type); } @@ -281,7 +281,7 @@ static int read_cumulative_state(data_set_t const *ds, value_list_t const *vl, char start_value_key[DATA_MAX_NAME_LEN]; ssnprintf(start_value_key, sizeof(start_value_key), - "stackdriver:start_value[%d]", ds_index); + "stackdriver:start_value[%d]", ds_index); int status = uc_meta_data_get_signed_int(vl, start_value_key, ret_start_value); diff --git a/src/utils/gce/gce.c b/src/utils/gce/gce.c index 0c97d909..48aacd98 100644 --- a/src/utils/gce/gce.c +++ b/src/utils/gce/gce.c @@ -228,7 +228,7 @@ char *gce_scope(char const *email) /* {{{ */ char url[1024]; ssnprintf(url, sizeof(url), GCE_SCOPE_URL_FORMAT, - (email != NULL) ? email : GCE_DEFAULT_SERVICE_ACCOUNT); + (email != NULL) ? email : GCE_DEFAULT_SERVICE_ACCOUNT); return read_url(url); } /* }}} char *gce_scope */ diff --git a/src/utils/oauth/oauth.c b/src/utils/oauth/oauth.c index b7b1978e..a7ae75d0 100644 --- a/src/utils/oauth/oauth.c +++ b/src/utils/oauth/oauth.c @@ -184,9 +184,9 @@ static int get_claim(oauth_t *auth, char *buffer, size_t buffer_size) /* {{{ */ /* create the claim set */ status = - ssnprintf(claim, sizeof(claim), OAUTH_CLAIM_FORMAT, auth->iss, auth->scope, - auth->aud, (unsigned long)CDTIME_T_TO_TIME_T(exp), - (unsigned long)CDTIME_T_TO_TIME_T(iat)); + ssnprintf(claim, sizeof(claim), OAUTH_CLAIM_FORMAT, auth->iss, + auth->scope, auth->aud, (unsigned long)CDTIME_T_TO_TIME_T(exp), + (unsigned long)CDTIME_T_TO_TIME_T(iat)); if (status < 1) return -1; else if ((size_t)status >= sizeof(claim)) @@ -351,7 +351,7 @@ static int new_token(oauth_t *auth) /* {{{ */ } ssnprintf(post_data, sizeof(post_data), "grant_type=%s&assertion=%s", - OAUTH_GRANT_TYPE, assertion); + OAUTH_GRANT_TYPE, assertion); curl = curl_easy_init(); if (curl == NULL) { @@ -531,7 +531,8 @@ 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); @@ -590,7 +591,7 @@ oauth_google_t oauth_create_google_default(char const *scope) { if ((home = getenv("HOME")) != NULL) { char path[PATH_MAX]; ssnprintf(path, sizeof(path), - "%s/.config/gcloud/application_default_credentials.json", home); + "%s/.config/gcloud/application_default_credentials.json", home); oauth_google_t ret = oauth_create_google_file(path, scope); if (ret.oauth != NULL) { diff --git a/src/utils/ovs/ovs.c b/src/utils/ovs/ovs.c index 127a9178..52a590b1 100644 --- a/src/utils/ovs/ovs.c +++ b/src/utils/ovs/ovs.c @@ -785,7 +785,9 @@ 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/utils/rrdcreate/rrdcreate.c b/src/utils/rrdcreate/rrdcreate.c index 6a2e09a2..7a2867c5 100644 --- a/src/utils/rrdcreate/rrdcreate.c +++ b/src/utils/rrdcreate/rrdcreate.c @@ -209,7 +209,7 @@ static int rra_get(char ***ret, const value_list_t *vl, /* {{{ */ break; status = ssnprintf(buffer, sizeof(buffer), "RRA:%s:%.10f:%u:%u", - rra_types[j], cfg->xff, cdp_len, cdp_num); + rra_types[j], cfg->xff, cdp_len, cdp_num); if ((status < 0) || ((size_t)status >= sizeof(buffer))) { P_ERROR("rra_get: Buffer would have been truncated."); diff --git a/src/varnish.c b/src/varnish.c index 339343a3..f4c70af8 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -108,7 +108,7 @@ static int varnish_submit(const char *plugin_instance, /* {{{ */ if (plugin_instance == NULL) plugin_instance = "default"; ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%s", - plugin_instance, category); + plugin_instance, category); sstrncpy(vl.type, type, sizeof(vl.type)); @@ -1546,7 +1546,8 @@ 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; @@ -1751,7 +1752,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); @@ -1760,7 +1761,7 @@ static int varnish_config_instance(const oconfig_item_t *ci) /* {{{ */ } ssnprintf(callback_name, sizeof(callback_name), "varnish/%s", - (conf->instance == NULL) ? "localhost" : conf->instance); + (conf->instance == NULL) ? "localhost" : conf->instance); plugin_register_complex_read( /* group = */ "varnish", @@ -1768,7 +1769,8 @@ 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 259f37e9..1f4172ff 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,107 +352,99 @@ 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 */ @@ -957,7 +949,8 @@ 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)); @@ -1032,7 +1025,7 @@ static void disk_block_stats_submit(struct lv_block_stats *bstats, char flush_type_instance[DATA_MAX_NAME_LEN]; ssnprintf(flush_type_instance, sizeof(flush_type_instance), "flush-%s", - type_instance); + type_instance); if ((bstats->bi.rd_req != -1) && (bstats->bi.wr_req != -1)) submit_derive2("disk_ops", (derive_t)bstats->bi.rd_req, @@ -1136,7 +1129,7 @@ static void domain_state_submit_notif(virDomainPtr dom, int state, int reason) { #endif ssnprintf(msg, sizeof(msg), "Domain state: %s. Reason: %s", state_str, - reason_str); + reason_str); int severity; switch (state) { @@ -1592,7 +1585,8 @@ static void vcpu_pin_submit(virDomainPtr dom, int max_cpus, int vcpu, char type_instance[DATA_MAX_NAME_LEN]; bool is_set = VIR_CPU_USABLE(cpu_maps, cpu_map_len, vcpu, cpu); - ssnprintf(type_instance, sizeof(type_instance), "vcpu_%d-cpu_%d", vcpu, cpu); + ssnprintf(type_instance, sizeof(type_instance), "vcpu_%d-cpu_%d", vcpu, + cpu); submit(dom, "cpu_affinity", type_instance, &(value_t){.gauge = is_set}, 1); } } @@ -1717,7 +1711,8 @@ 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)); @@ -1801,7 +1796,8 @@ 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)); } @@ -2591,7 +2587,7 @@ static int lv_domain_get_tag(xmlXPathContextPtr xpath_ctx, const char *dom_name, } ssnprintf(xpath_str, sizeof(xpath_str), "/domain/metadata/%s:%s/text()", - METADATA_VM_PARTITION_PREFIX, METADATA_VM_PARTITION_ELEMENT); + METADATA_VM_PARTITION_PREFIX, METADATA_VM_PARTITION_ELEMENT); xpath_obj = xmlXPathEvalExpression((xmlChar *)xpath_str, xpath_ctx); if (xpath_obj == NULL) { ERROR(PLUGIN_NAME " plugin: xmlXPathEval(%s) failed on domain %s", diff --git a/src/write_kafka.c b/src/write_kafka.c index 4decc4e4..09bb639a 100644 --- a/src/write_kafka.c +++ b/src/write_kafka.c @@ -411,13 +411,13 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, rd_kafka_topic_conf_set_opaque(tctx->conf, tctx); ssnprintf(callback_name, sizeof(callback_name), "write_kafka/%s", - tctx->topic_name); + 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 5c745e7e..b9040223 100644 --- a/src/write_prometheus.c +++ b/src/write_prometheus.c @@ -156,7 +156,8 @@ 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}, }; @@ -165,7 +166,7 @@ static char *format_labels(char *buffer, size_t buffer_size, for (size_t i = 0; i < m->n_label; i++) { char value[LABEL_VALUE_SIZE]; ssnprintf(labels[i], LABEL_BUFFER_SIZE, "%s=\"%s\"", m->label[i]->name, - escape_label_value(value, sizeof(value), m->label[i]->value)); + escape_label_value(value, sizeof(value), m->label[i]->value)); } strjoin(buffer, buffer_size, labels, m->n_label, ","); @@ -187,9 +188,9 @@ static void format_text(ProtobufCBuffer *buffer) { buffer->append(buffer, strlen(line), (uint8_t *)line); ssnprintf(line, sizeof(line), "# TYPE %s %s\n", fam->name, - (fam->type == IO__PROMETHEUS__CLIENT__METRIC_TYPE__GAUGE) - ? "gauge" - : "counter"); + (fam->type == IO__PROMETHEUS__CLIENT__METRIC_TYPE__GAUGE) + ? "gauge" + : "counter"); buffer->append(buffer, strlen(line), (uint8_t *)line); for (size_t i = 0; i < fam->n_metric; i++) { @@ -200,16 +201,16 @@ static void format_text(ProtobufCBuffer *buffer) { char timestamp_ms[24] = ""; if (m->has_timestamp_ms) ssnprintf(timestamp_ms, sizeof(timestamp_ms), " %" PRIi64, - m->timestamp_ms); + m->timestamp_ms); if (fam->type == IO__PROMETHEUS__CLIENT__METRIC_TYPE__GAUGE) ssnprintf(line, sizeof(line), "%s{%s} " GAUGE_FORMAT "%s\n", fam->name, - format_labels(labels, sizeof(labels), m), m->gauge->value, - timestamp_ms); + format_labels(labels, sizeof(labels), m), m->gauge->value, + timestamp_ms); else /* if (fam->type == IO__PROMETHEUS__CLIENT__METRIC_TYPE__COUNTER) */ ssnprintf(line, sizeof(line), "%s{%s} %.0f%s\n", fam->name, - format_labels(labels, sizeof(labels), m), m->counter->value, - timestamp_ms); + format_labels(labels, sizeof(labels), m), m->counter->value, + timestamp_ms); buffer->append(buffer, strlen(line), (uint8_t *)line); } @@ -218,7 +219,7 @@ static void format_text(ProtobufCBuffer *buffer) { char server[1024]; ssnprintf(server, sizeof(server), "\n# collectd/write_prometheus %s at %s\n", - PACKAGE_VERSION, hostname_g); + PACKAGE_VERSION, hostname_g); buffer->append(buffer, strlen(server), (uint8_t *)server); pthread_mutex_unlock(&metrics_lock); diff --git a/src/write_redis.c b/src/write_redis.c index d8cc94fd..32005cd6 100644 --- a/src/write_redis.c +++ b/src/write_redis.c @@ -72,7 +72,8 @@ static int wr_write(const data_set_t *ds, /* {{{ */ if (status != 0) return status; ssnprintf(key, sizeof(key), "%s%s", - (node->prefix != NULL) ? node->prefix : REDIS_DEFAULT_PREFIX, ident); + (node->prefix != NULL) ? node->prefix : REDIS_DEFAULT_PREFIX, + ident); ssnprintf(time, sizeof(time), "%.9f", CDTIME_T_TO_DOUBLE(vl->time)); value_size = sizeof(value); @@ -241,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) diff --git a/src/write_riemann.c b/src/write_riemann.c index e6ac2e21..201ac516 100644 --- a/src/write_riemann.c +++ b/src/write_riemann.c @@ -291,17 +291,18 @@ wrr_value_to_event(struct riemann_host const *host, /* {{{ */ vl->type_instance); if (host->always_append_ds || (ds->ds_num > 1)) { if (host->event_service_prefix == NULL) - ssnprintf(service_buffer, sizeof(service_buffer), "%s/%s", &name_buffer[1], - ds->ds[index].name); + ssnprintf(service_buffer, sizeof(service_buffer), "%s/%s", + &name_buffer[1], ds->ds[index].name); else ssnprintf(service_buffer, sizeof(service_buffer), "%s%s/%s", - host->event_service_prefix, &name_buffer[1], ds->ds[index].name); + host->event_service_prefix, &name_buffer[1], + ds->ds[index].name); } else { if (host->event_service_prefix == NULL) sstrncpy(service_buffer, &name_buffer[1], sizeof(service_buffer)); else ssnprintf(service_buffer, sizeof(service_buffer), "%s%s", - host->event_service_prefix, &name_buffer[1]); + host->event_service_prefix, &name_buffer[1]); } riemann_event_set( @@ -350,7 +351,7 @@ wrr_value_to_event(struct riemann_host const *host, /* {{{ */ char ds_type[DATA_MAX_NAME_LEN]; ssnprintf(ds_type, sizeof(ds_type), "%s:rate", - DS_TYPE_TO_STRING(ds->ds[index].type)); + DS_TYPE_TO_STRING(ds->ds[index].type)); riemann_event_string_attribute_add(event, "ds_type", ds_type); } else { riemann_event_string_attribute_add(event, "ds_type", @@ -795,7 +796,7 @@ static int wrr_config_node(oconfig_item_t *ci) /* {{{ */ } ssnprintf(callback_name, sizeof(callback_name), "write_riemann/%s", - host->name); + host->name); user_data_t ud = {.data = host, .free_func = wrr_free}; diff --git a/src/write_stackdriver.c b/src/write_stackdriver.c index 46d9aa8c..dfa1d7c0 100644 --- a/src/write_stackdriver.c +++ b/src/write_stackdriver.c @@ -110,7 +110,7 @@ static char *wg_get_authorization_header(wg_callback_t *cb) { /* {{{ */ } status = ssnprintf(authorization_header, sizeof(authorization_header), - "Authorization: Bearer %s", access_token); + "Authorization: Bearer %s", access_token); if ((status < 1) || ((size_t)status >= sizeof(authorization_header))) return NULL; @@ -252,7 +252,7 @@ static int wg_call_metricdescriptor_create(wg_callback_t *cb, char const *payload) { char url[1024]; ssnprintf(url, sizeof(url), "%s/projects/%s/metricDescriptors", cb->url, - cb->project); + cb->project); wg_memory_t response = {0}; int status = do_post(cb, url, payload, &response); @@ -273,7 +273,8 @@ static int wg_call_metricdescriptor_create(wg_callback_t *cb, static int wg_call_timeseries_write(wg_callback_t *cb, char const *payload) { char url[1024]; - ssnprintf(url, sizeof(url), "%s/projects/%s/timeSeries", cb->url, cb->project); + ssnprintf(url, sizeof(url), "%s/projects/%s/timeSeries", cb->url, + cb->project); wg_memory_t response = {0}; int status = do_post(cb, url, payload, &response); -- 2.11.0