From 6e41c3b1f024d7944e5e8010a87933555c662474 Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Sun, 13 May 2018 20:38:40 +0200 Subject: [PATCH] Use true and false for assignments to bool --- src/aggregation.c | 22 ++++++------- src/amqp.c | 14 ++++---- src/apcups.c | 8 ++--- src/barometer.c | 4 +-- src/battery.c | 14 ++++---- src/ceph.c | 14 ++++---- src/ceph_test.c | 6 ++-- src/cgroups.c | 4 +-- src/collectd-nagios.c | 2 +- src/collectd-tg.c | 2 +- src/cpu.c | 18 +++++------ src/curl.c | 10 +++--- src/curl_json.c | 4 +-- src/daemon/collectd.c | 12 +++---- src/daemon/configfile.c | 13 ++++---- src/daemon/plugin.c | 24 +++++++------- src/daemon/plugin.h | 2 +- src/daemon/utils_complain.c | 6 ++-- src/daemon/utils_complain.h | 2 +- src/daemon/utils_random.c | 2 +- src/dbi.c | 2 +- src/df.c | 14 ++++---- src/disk.c | 8 ++--- src/dpdkevents.c | 8 ++--- src/fhcount.c | 8 ++--- src/grpc.cc | 2 +- src/hugepages.c | 12 +++---- src/interface.c | 2 +- src/ipmi.c | 18 +++++------ src/libcollectdclient/network_buffer.c | 14 ++++---- src/load.c | 2 +- src/log_logstash.c | 8 ++--- src/logfile.c | 4 +-- src/lpar.c | 12 +++---- src/match_regex.c | 2 +- src/mcelog.c | 2 +- src/memcached.c | 4 +-- src/memory.c | 10 +++--- src/modbus.c | 4 +-- src/mqtt.c | 20 ++++++------ src/mysql.c | 16 +++++----- src/netapp.c | 4 +-- src/netlink.c | 4 +-- src/network.c | 6 ++-- src/ntpd.c | 8 ++--- src/onewire.c | 4 +-- src/openldap.c | 8 ++--- src/openvpn.c | 32 +++++++++---------- src/ovs_events.c | 10 +++--- src/perl.c | 10 +++--- src/pf.c | 10 +++--- src/pinba.c | 10 +++--- src/ping.c | 4 +-- src/postgresql.c | 12 +++---- src/processes.c | 20 ++++++------ src/rrdcached.c | 12 +++---- src/sensors.c | 2 +- src/serial.c | 7 ++-- src/snmp.c | 3 +- src/statsd.c | 6 ++-- src/swap.c | 10 +++--- src/tail_csv.c | 6 ++-- src/target_replace.c | 24 +++++++------- src/target_v5upgrade.c | 4 +-- src/thermal.c | 10 +++--- src/turbostat.c | 58 +++++++++++++++++----------------- src/unixsock.c | 4 +-- src/utils_cmd_putval.c | 2 +- src/utils_format_graphite.c | 2 +- src/utils_format_json.c | 2 +- src/utils_vl_lookup.c | 20 ++++++------ src/utils_vl_lookup_test.c | 4 +-- src/varnish.c | 56 ++++++++++++++++---------------- src/virt.c | 4 +-- src/write_graphite.c | 8 ++--- src/write_http.c | 10 +++--- src/write_kafka.c | 2 +- src/write_log.c | 4 +-- src/write_mongodb.c | 20 ++++++------ src/write_prometheus.c | 4 +-- src/write_redis.c | 2 +- src/write_riemann.c | 10 +++--- src/write_sensu.c | 15 +++++---- 83 files changed, 404 insertions(+), 404 deletions(-) diff --git a/src/aggregation.c b/src/aggregation.c index 64c641f8..7d35d41f 100644 --- a/src/aggregation.c +++ b/src/aggregation.c @@ -91,16 +91,16 @@ static agg_instance_t *agg_instance_list_head = NULL; static bool agg_is_regex(char const *str) /* {{{ */ { if (str == NULL) - return 0; + return false; size_t len = strlen(str); if (len < 3) - return 0; + return false; if ((str[0] == '/') && (str[len - 1] == '/')) - return 1; + return true; else - return 0; + return false; } /* }}} bool agg_is_regex */ static void agg_destroy(aggregation_t *agg) /* {{{ */ @@ -571,7 +571,7 @@ static int agg_config_aggregation(oconfig_item_t *ci) /* {{{ */ agg->regex_fields |= LU_GROUP_BY_TYPE_INSTANCE; /* Sanity checking */ - bool is_valid = 1; + bool is_valid = true; if (strcmp("/.*/", agg->ident.type) == 0) /* {{{ */ { ERROR("aggregation plugin: It appears you did not specify the required " @@ -580,13 +580,13 @@ static int agg_config_aggregation(oconfig_item_t *ci) /* {{{ */ "Type \"%s\", TypeInstance \"%s\")", agg->ident.host, agg->ident.plugin, agg->ident.plugin_instance, agg->ident.type, agg->ident.type_instance); - is_valid = 0; + is_valid = false; } else if (strchr(agg->ident.type, '/') != NULL) { ERROR("aggregation plugin: The \"Type\" may not contain the '/' " "character. Especially, it may not be a regex. The current " "value is \"%s\".", agg->ident.type); - is_valid = 0; + is_valid = false; } /* }}} */ /* Check that there is at least one regex field without a grouping. {{{ */ @@ -599,7 +599,7 @@ static int agg_config_aggregation(oconfig_item_t *ci) /* {{{ */ "Type \"%s\", TypeInstance \"%s\")", agg->ident.host, agg->ident.plugin, agg->ident.plugin_instance, agg->ident.type, agg->ident.type_instance); - is_valid = 0; + is_valid = false; } /* }}} */ /* Check that all grouping fields are regular expressions. {{{ */ @@ -611,7 +611,7 @@ static int agg_config_aggregation(oconfig_item_t *ci) /* {{{ */ "Type \"%s\", TypeInstance \"%s\")", agg->ident.host, agg->ident.plugin, agg->ident.plugin_instance, agg->ident.type, agg->ident.type_instance); - is_valid = 0; + is_valid = false; } /* }}} */ if (!agg->calc_num && !agg->calc_sum && !agg->calc_average /* {{{ */ @@ -622,7 +622,7 @@ static int agg_config_aggregation(oconfig_item_t *ci) /* {{{ */ "Type \"%s\", TypeInstance \"%s\")", agg->ident.host, agg->ident.plugin, agg->ident.plugin_instance, agg->ident.type, agg->ident.type_instance); - is_valid = 0; + is_valid = false; } /* }}} */ if (!is_valid) { /* {{{ */ @@ -712,7 +712,7 @@ static int agg_read(void) /* {{{ */ static int agg_write(data_set_t const *ds, value_list_t const *vl, /* {{{ */ __attribute__((unused)) user_data_t *user_data) { - bool created_by_aggregation = 0; + bool created_by_aggregation = false; /* Ignore values that were created by the aggregation plugin to avoid weird * effects. */ (void)meta_data_get_boolean(vl->meta, "aggregation:created", diff --git a/src/amqp.c b/src/amqp.c index 6d65bf83..15579233 100644 --- a/src/amqp.c +++ b/src/amqp.c @@ -182,9 +182,9 @@ static bool camqp_is_error(camqp_config_t *conf) /* {{{ */ r = amqp_get_rpc_reply(conf->connection); if (r.reply_type == AMQP_RESPONSE_NORMAL) - return 0; + return false; - return 1; + return true; } /* }}} bool camqp_is_error */ static char *camqp_strerror(camqp_config_t *conf, /* {{{ */ @@ -850,7 +850,7 @@ static int camqp_config_connection(oconfig_item_t *ci, /* {{{ */ /* publish only */ conf->delivery_mode = CAMQP_DM_VOLATILE; - conf->store_rates = 0; + conf->store_rates = false; conf->graphite_flags = 0; /* publish & graphite only */ conf->prefix = NULL; @@ -859,8 +859,8 @@ static int camqp_config_connection(oconfig_item_t *ci, /* {{{ */ /* subscribe only */ conf->exchange_type = NULL; conf->queue = NULL; - conf->queue_durable = 0; - conf->queue_auto_delete = 1; + conf->queue_durable = false; + conf->queue_auto_delete = true; /* general */ conf->connection = NULL; pthread_mutex_init(&conf->lock, /* attr = */ NULL); @@ -998,9 +998,9 @@ static int camqp_config(oconfig_item_t *ci) /* {{{ */ oconfig_item_t *child = ci->children + i; if (strcasecmp("Publish", child->key) == 0) - camqp_config_connection(child, /* publish = */ 1); + camqp_config_connection(child, /* publish = */ true); else if (strcasecmp("Subscribe", child->key) == 0) - camqp_config_connection(child, /* publish = */ 0); + camqp_config_connection(child, /* publish = */ false); else WARNING("amqp plugin: Ignoring unknown config option \"%s\".", child->key); diff --git a/src/apcups.c b/src/apcups.c index 622e3a10..4b3f7b5c 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -285,7 +285,7 @@ static int apc_query_server(char const *node, char const *service, "first %i iterations. Will close the socket " "in future iterations.", count_retries, count_iterations); - conf_persistent_conn = 0; + conf_persistent_conn = false; } while ((n = net_recv(&global_sockfd, recvline, sizeof(recvline) - 1)) > 0) { @@ -347,7 +347,7 @@ static int apc_query_server(char const *node, char const *service, } static int apcups_config(oconfig_item_t *ci) { - bool persistent_conn_set = 0; + bool persistent_conn_set = false; for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; @@ -360,7 +360,7 @@ static int apcups_config(oconfig_item_t *ci) { cf_util_get_boolean(child, &conf_report_seconds); else if (strcasecmp(child->key, "PersistentConnection") == 0) { cf_util_get_boolean(child, &conf_persistent_conn); - persistent_conn_set = 1; + persistent_conn_set = true; } else ERROR("apcups plugin: Unknown config option \"%s\".", child->key); } @@ -372,7 +372,7 @@ static int apcups_config(oconfig_item_t *ci) { "Apcupsd NIS socket timeout is %.3f seconds, " "PersistentConnection disabled by default.", interval, APCUPS_SERVER_TIMEOUT); - conf_persistent_conn = 0; + conf_persistent_conn = false; } } diff --git a/src/barometer.c b/src/barometer.c index 6945442c..e55e3b8c 100644 --- a/src/barometer.c +++ b/src/barometer.c @@ -1392,7 +1392,7 @@ static int MPL115_collectd_barometer_read(void) { config_oversample - 1); usleep(20000); } - avg_initialized = 1; + avg_initialized = true; } result = MPL115_read_averaged(&pressure, &temperature); @@ -1635,7 +1635,7 @@ static int collectd_barometer_init(void) { return -1; } - configured = 1; + configured = true; return 0; } diff --git a/src/battery.c b/src/battery.c index 0e2667c9..a74e7b64 100644 --- a/src/battery.c +++ b/src/battery.c @@ -410,7 +410,7 @@ static int read_sysfs_callback(char const *dir, /* {{{ */ char const *plugin_instance; char buffer[32]; gauge_t v = NAN; - bool discharging = 0; + bool discharging = false; int status; /* Ignore non-battery directories, such as AC power. */ @@ -424,7 +424,7 @@ static int read_sysfs_callback(char const *dir, /* {{{ */ (void)sysfs_file_to_buffer(dir, power_supply, "status", buffer, sizeof(buffer)); if (strcasecmp("Discharging", buffer) == 0) - discharging = 1; + discharging = true; /* FIXME: This is a dirty hack for backwards compatibility: The battery * plugin, for a very long time, has had the plugin_instance @@ -522,8 +522,8 @@ static int read_acpi_callback(char const *dir, /* {{{ */ gauge_t capacity_charged = NAN; gauge_t capacity_full = NAN; gauge_t capacity_design = NAN; - bool charging = 0; - bool is_current = 0; + bool charging = false; + bool is_current = false; char const *plugin_instance; char filename[PATH_MAX]; @@ -560,9 +560,9 @@ static int read_acpi_callback(char const *dir, /* {{{ */ if ((strcmp(fields[0], "charging") == 0) && (strcmp(fields[1], "state:") == 0)) { if (strcmp(fields[2], "charging") == 0) - charging = 1; + charging = true; else - charging = 0; + charging = false; continue; } @@ -575,7 +575,7 @@ static int read_acpi_callback(char const *dir, /* {{{ */ strtogauge(fields[2], &power); if ((numfields >= 4) && (strcmp("mA", fields[3]) == 0)) - is_current = 1; + is_current = true; } else if ((strcmp(fields[0], "remaining") == 0) && (strcmp(fields[1], "capacity:") == 0)) strtogauge(fields[2], &capacity_charged); diff --git a/src/ceph.c b/src/ceph.c index 9027771e..804514ca 100644 --- a/src/ceph.c +++ b/src/ceph.c @@ -404,8 +404,8 @@ static int compact_ds_name(char *buffer, size_t buffer_size, char const *src) { size_t src_len; char *ptr = buffer; size_t ptr_size = buffer_size; - bool append_plus = 0; - bool append_minus = 0; + bool append_plus = false; + bool append_minus = false; if ((buffer == NULL) || (buffer_size <= strlen("Minus")) || (src == NULL)) return EINVAL; @@ -415,11 +415,11 @@ static int compact_ds_name(char *buffer, size_t buffer_size, char const *src) { /* Remove trailing "+" and "-". */ if (src_copy[src_len - 1] == '+') { - append_plus = 1; + append_plus = true; src_len--; src_copy[src_len] = 0; } else if (src_copy[src_len - 1] == '-') { - append_minus = 1; + append_minus = true; src_len--; src_copy[src_len] = 0; } @@ -476,13 +476,13 @@ static bool has_suffix(char const *str, char const *suffix) { size_t offset; if (suffix_len > str_len) - return 0; + return false; offset = str_len - suffix_len; if (strcmp(str + offset, suffix) == 0) - return 1; + return true; - return 0; + return false; } static void cut_suffix(char *buffer, size_t buffer_size, char const *str, diff --git a/src/ceph_test.c b/src/ceph_test.c index b3c8f0bc..e4032929 100644 --- a/src/ceph_test.c +++ b/src/ceph_test.c @@ -47,7 +47,7 @@ static int test_handler(void *user, char const *val, char const *key) { snprintf(status, sizeof(status), "unexpected call: test_handler(\"%s\") = \"%s\"", key, val); - ok = 0; + ok = false; for (i = 0; i < t->cases_num; i++) { if (strcmp(key, t->cases[i].key) != 0) @@ -57,12 +57,12 @@ static int test_handler(void *user, char const *val, char const *key) { snprintf(status, sizeof(status), "test_handler(\"%s\") = \"%s\", want \"%s\"", key, val, t->cases[i].value); - ok = 0; + ok = false; break; } snprintf(status, sizeof(status), "test_handler(\"%s\") = \"%s\"", key, val); - ok = 1; + ok = true; break; } diff --git a/src/cgroups.c b/src/cgroups.c index 103e70f6..5830c7ba 100644 --- a/src/cgroups.c +++ b/src/cgroups.c @@ -181,7 +181,7 @@ static int cgroups_config(const char *key, const char *value) { static int cgroups_read(void) { cu_mount_t *mnt_list = NULL; - bool cgroup_found = 0; + bool cgroup_found = false; if (cu_mount_getlist(&mnt_list) == NULL) { ERROR("cgroups plugin: cu_mount_getlist failed."); @@ -199,7 +199,7 @@ static int cgroups_read(void) { walk_directory(mnt_ptr->dir, read_cpuacct_root, /* user_data = */ NULL, /* include_hidden = */ 0); - cgroup_found = 1; + cgroup_found = true; /* It doesn't make sense to check other cpuacct mount-points * (if any), they contain the same data. */ break; diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index d53ae655..2c9bf4a7 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -638,7 +638,7 @@ int main(int argc, char **argv) { break; } case 'm': - nan_is_error_g = 1; + nan_is_error_g = true; break; default: usage(argv[0]); diff --git a/src/collectd-tg.c b/src/collectd-tg.c index 170df2a6..64547b80 100644 --- a/src/collectd-tg.c +++ b/src/collectd-tg.c @@ -97,7 +97,7 @@ __attribute__((noreturn)) static void exit_usage(int exit_status) /* {{{ */ static void signal_handler(int signal) /* {{{ */ { - loop = 0; + loop = false; } /* }}} void signal_handler */ #if HAVE_CLOCK_GETTIME diff --git a/src/cpu.c b/src/cpu.c index 6db86293..5a32b6b2 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -209,17 +209,17 @@ static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); static int cpu_config(char const *key, char const *value) /* {{{ */ { if (strcasecmp(key, "ReportByCpu") == 0) - report_by_cpu = IS_TRUE(value) ? 1 : 0; + report_by_cpu = IS_TRUE(value); else if (strcasecmp(key, "ValuesPercentage") == 0) - report_percent = IS_TRUE(value) ? 1 : 0; + report_percent = IS_TRUE(value); else if (strcasecmp(key, "ReportByState") == 0) - report_by_state = IS_TRUE(value) ? 1 : 0; + report_by_state = IS_TRUE(value); else if (strcasecmp(key, "ReportNumCpu") == 0) - report_num_cpu = IS_TRUE(value) ? 1 : 0; + report_num_cpu = IS_TRUE(value); else if (strcasecmp(key, "ReportGuestState") == 0) - report_guest = IS_TRUE(value) ? 1 : 0; + report_guest = IS_TRUE(value); else if (strcasecmp(key, "SubtractGuestState") == 0) - subtract_guest = IS_TRUE(value) ? 1 : 0; + subtract_guest = IS_TRUE(value); else return -1; @@ -431,7 +431,7 @@ static void aggregate(gauge_t *sum_by_state) /* {{{ */ } if (!isnan(this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate)) - this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].has_value = 1; + this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].has_value = true; RATE_ADD(sum_by_state[COLLECTD_CPU_STATE_ACTIVE], this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate); @@ -505,7 +505,7 @@ static void cpu_commit_num_cpu(gauge_t value) /* {{{ */ static void cpu_reset(void) /* {{{ */ { for (size_t i = 0; i < cpu_states_num; i++) - cpu_states[i].has_value = 0; + cpu_states[i].has_value = false; global_cpu_num = 0; } /* }}} void cpu_reset */ @@ -588,7 +588,7 @@ static int cpu_stage(size_t cpu_num, size_t state, derive_t d, return status; s->rate = rate; - s->has_value = 1; + s->has_value = true; return 0; } /* }}} int cpu_stage */ diff --git a/src/curl.c b/src/curl.c index 12bf8cd5..769ba23a 100644 --- a/src/curl.c +++ b/src/curl.c @@ -418,11 +418,11 @@ static int cc_config_add_page(oconfig_item_t *ci) /* {{{ */ page->url = NULL; page->user = NULL; page->pass = NULL; - page->digest = 0; - page->verify_peer = 1; - page->verify_host = 1; - page->response_time = 0; - page->response_code = 0; + page->digest = false; + page->verify_peer = true; + page->verify_host = true; + page->response_time = false; + page->response_code = false; page->timeout = -1; page->stats = NULL; diff --git a/src/curl_json.c b/src/curl_json.c index 1a1136a9..f0badc99 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -325,7 +325,7 @@ static int cj_cb_start_array(void *ctx) { return CJ_CB_ABORT; } db->depth++; - db->state[db->depth].in_array = 1; + db->state[db->depth].in_array = true; db->state[db->depth].index = 0; cj_load_key(db, "0"); @@ -335,7 +335,7 @@ static int cj_cb_start_array(void *ctx) { static int cj_cb_end_array(void *ctx) { cj_t *db = (cj_t *)ctx; - db->state[db->depth].in_array = 0; + db->state[db->depth].in_array = false; return cj_cb_end(ctx); } diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c index 133b49ec..3b959c76 100644 --- a/src/daemon/collectd.c +++ b/src/daemon/collectd.c @@ -464,19 +464,19 @@ static void read_cmdline(int argc, char **argv, struct cmdline_config *config) { switch (c) { case 'B': - config->create_basedir = 0; + config->create_basedir = false; break; case 'C': config->configfile = optarg; break; case 't': - config->test_config = 1; + config->test_config = true; break; case 'T': - config->test_readall = 1; + config->test_readall = true; global_option_set("ReadThreads", "-1", 1); #if COLLECT_DAEMON - config->daemonize = 0; + config->daemonize = false; #endif /* COLLECT_DAEMON */ break; #if COLLECT_DAEMON @@ -484,7 +484,7 @@ static void read_cmdline(int argc, char **argv, struct cmdline_config *config) { global_option_set("PIDFile", optarg, 1); break; case 'f': - config->daemonize = 0; + config->daemonize = false; break; #endif /* COLLECT_DAEMON */ case 'h': @@ -542,7 +542,7 @@ int main(int argc, char **argv) { int exit_status = 0; struct cmdline_config config = { - .daemonize = 1, .create_basedir = 1, .configfile = CONFIGFILE, + .daemonize = true, .create_basedir = true, .configfile = CONFIGFILE, }; read_cmdline(argc, argv, &config); diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index 97fe42b6..e8d1092a 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -245,7 +245,7 @@ static int dispatch_value_plugindir(oconfig_item_t *ci) { static int dispatch_loadplugin(oconfig_item_t *ci) { const char *name; - bool global = 0; + bool global = false; plugin_ctx_t ctx = {0}; plugin_ctx_t old_ctx; int ret_val; @@ -372,7 +372,7 @@ static int dispatch_block_plugin(oconfig_item_t *ci) { ctx.interval = cf_get_default_interval(); old_ctx = plugin_set_ctx(ctx); - status = plugin_load(name, /* flags = */ 0); + status = plugin_load(name, /* flags = */ false); /* reset to the "global" context */ plugin_set_ctx(old_ctx); @@ -1125,7 +1125,7 @@ int cf_util_get_boolean(const oconfig_item_t *ci, bool *ret_bool) /* {{{ */ switch (ci->values[0].type) { case OCONFIG_TYPE_BOOLEAN: - *ret_bool = ci->values[0].value.boolean ? 1 : 0; + *ret_bool = ci->values[0].value.boolean ? true : false; break; case OCONFIG_TYPE_STRING: WARNING("cf_util_get_boolean: Using string value `%s' for boolean option " @@ -1134,9 +1134,9 @@ int cf_util_get_boolean(const oconfig_item_t *ci, bool *ret_bool) /* {{{ */ ci->values[0].value.string, ci->key); if (IS_TRUE(ci->values[0].value.string)) - *ret_bool = 1; + *ret_bool = true; else if (IS_FALSE(ci->values[0].value.string)) - *ret_bool = 0; + *ret_bool = false; else { ERROR("cf_util_get_boolean: Cannot parse string value `%s' of the `%s' " "option as a boolean value.", @@ -1152,12 +1152,11 @@ int cf_util_get_boolean(const oconfig_item_t *ci, bool *ret_bool) /* {{{ */ int cf_util_get_flag(const oconfig_item_t *ci, /* {{{ */ unsigned int *ret_value, unsigned int flag) { int status; - bool b; if (ret_value == NULL) return EINVAL; - b = 0; + bool b = false; status = cf_util_get_boolean(ci, &b); if (status != 0) return status; diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c index 6752a6c1..734e8a0a 100644 --- a/src/daemon/plugin.c +++ b/src/daemon/plugin.c @@ -861,7 +861,7 @@ static void stop_write_threads(void) /* {{{ */ INFO("collectd: Stopping %" PRIsz " write threads.", write_threads_num); pthread_mutex_lock(&write_lock); - write_loop = 0; + write_loop = false; DEBUG("plugin: stop_write_threads: Signalling `write_cond'"); pthread_cond_broadcast(&write_cond); pthread_mutex_unlock(&write_lock); @@ -988,7 +988,7 @@ int plugin_load(char const *plugin_name, bool global) { */ if ((strcasecmp("perl", plugin_name) == 0) || (strcasecmp("python", plugin_name) == 0)) - global = 1; + global = true; /* `cpu' should not match `cpufreq'. To solve this we add `.so' to the * type when matching the filename */ @@ -1545,7 +1545,7 @@ int plugin_init_all(void) { uc_init(); if (IS_TRUE(global_option_get("CollectInternalStats"))) { - record_statistics = 1; + record_statistics = true; plugin_register_read("collectd", plugin_update_internal_statistics); } @@ -1890,7 +1890,7 @@ static int plugin_dispatch_values_internal(value_list_t *vl) { int status; static c_complain_t no_write_complaint = C_COMPLAIN_INIT_STATIC; - bool free_meta_data = 0; + bool free_meta_data = false; assert(vl != NULL); @@ -1910,7 +1910,7 @@ static int plugin_dispatch_values_internal(value_list_t *vl) { * this case matches and targets may add some and the calling function * may not expect (and therefore free) that data. */ if (vl->meta == NULL) - free_meta_data = 1; + free_meta_data = true; if (list_write == NULL) c_complain_once(LOG_WARNING, &no_write_complaint, @@ -1994,7 +1994,7 @@ static int plugin_dispatch_values_internal(value_list_t *vl) { } else fc_default_action(ds, vl); - if ((free_meta_data != 0) && (vl->meta != NULL)) { + if ((free_meta_data == true) && (vl->meta != NULL)) { meta_data_destroy(vl->meta); vl->meta = NULL; } @@ -2033,11 +2033,11 @@ static bool check_drop_value(void) /* {{{ */ int status; if (write_limit_high == 0) - return 0; + return false; p = get_drop_probability(); if (p == 0.0) - return 0; + return false; status = pthread_mutex_trylock(&last_message_lock); if (status == 0) { @@ -2054,13 +2054,13 @@ static bool check_drop_value(void) /* {{{ */ } if (p == 1.0) - return 1; + return true; q = cdrand_d(); if (q > p) - return 1; + return true; else - return 0; + return false; } /* }}} bool check_drop_value */ int plugin_dispatch_values(value_list_t const *vl) { @@ -2460,7 +2460,7 @@ static plugin_ctx_t *plugin_ctx_create(void) { void plugin_init_ctx(void) { pthread_key_create(&plugin_ctx_key, plugin_ctx_destructor); - plugin_ctx_key_initialized = 1; + plugin_ctx_key_initialized = true; } /* void plugin_init_ctx */ plugin_ctx_t plugin_get_ctx(void) { diff --git a/src/daemon/plugin.h b/src/daemon/plugin.h index 48a45cb1..03690678 100644 --- a/src/daemon/plugin.h +++ b/src/daemon/plugin.h @@ -346,7 +346,7 @@ int plugin_dispatch_values(value_list_t const *vl); * plugin_dispatch_multivalue * * SYNOPSIS - * plugin_dispatch_multivalue (vl, 1, DS_TYPE_GAUGE, + * plugin_dispatch_multivalue (vl, true, DS_TYPE_GAUGE, * "free", 42.0, * "used", 58.0, * NULL); diff --git a/src/daemon/utils_complain.c b/src/daemon/utils_complain.c index d2162ba7..e34cf6fc 100644 --- a/src/daemon/utils_complain.c +++ b/src/daemon/utils_complain.c @@ -64,7 +64,7 @@ void c_complain(int level, c_complain_t *c, const char *format, ...) { va_start(ap, format); if (vcomplain(level, c, format, ap)) - c->complained_once = 1; + c->complained_once = true; va_end(ap); } /* c_complain */ @@ -76,7 +76,7 @@ void c_complain_once(int level, c_complain_t *c, const char *format, ...) { va_start(ap, format); if (vcomplain(level, c, format, ap)) - c->complained_once = 1; + c->complained_once = true; va_end(ap); } /* c_complain_once */ @@ -88,7 +88,7 @@ void c_do_release(int level, c_complain_t *c, const char *format, ...) { return; c->interval = 0; - c->complained_once = 0; + c->complained_once = false; va_start(ap, format); vsnprintf(message, sizeof(message), format, ap); diff --git a/src/daemon/utils_complain.h b/src/daemon/utils_complain.h index 0ddb7bfd..88387be4 100644 --- a/src/daemon/utils_complain.h +++ b/src/daemon/utils_complain.h @@ -48,7 +48,7 @@ typedef struct { do { \ (c)->last = 0; \ (c)->interval = 0; \ - (c)->complained_once = 0; \ + (c)->complained_once = false; \ } while (0) /* diff --git a/src/daemon/utils_random.c b/src/daemon/utils_random.c index e3ce34cd..7a9ce7be 100644 --- a/src/daemon/utils_random.c +++ b/src/daemon/utils_random.c @@ -47,7 +47,7 @@ static void cdrand_seed(void) { seed[1] = (unsigned short)(t >> 16); seed[2] = (unsigned short)(t >> 32); - have_seed = 1; + have_seed = true; } double cdrand_d(void) { diff --git a/src/dbi.c b/src/dbi.c index a61f66bc..5f8520f3 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -258,7 +258,7 @@ static int cdbi_config_add_database_driver_option(cdbi_database_t *db, /* {{{ */ } else { assert(ci->values[1].type == OCONFIG_TYPE_NUMBER); option->value.numeric = (int)(ci->values[1].value.number + .5); - option->is_numeric = 1; + option->is_numeric = true; } db->driver_options_num++; diff --git a/src/df.c b/src/df.c index d8108e3f..3cade6a2 100644 --- a/src/df.c +++ b/src/df.c @@ -99,28 +99,28 @@ static int df_config(const char *key, const char *value) { return 0; } else if (strcasecmp(key, "ReportByDevice") == 0) { if (IS_TRUE(value)) - by_device = 1; + by_device = true; return 0; } else if (strcasecmp(key, "ReportInodes") == 0) { if (IS_TRUE(value)) - report_inodes = 1; + report_inodes = true; else - report_inodes = 0; + report_inodes = false; return 0; } else if (strcasecmp(key, "ValuesAbsolute") == 0) { if (IS_TRUE(value)) - values_absolute = 1; + values_absolute = true; else - values_absolute = 0; + values_absolute = false; return 0; } else if (strcasecmp(key, "ValuesPercentage") == 0) { if (IS_TRUE(value)) - values_percentage = 1; + values_percentage = true; else - values_percentage = 0; + values_percentage = false; return 0; } diff --git a/src/disk.c b/src/disk.c index 506c0e0a..962b7c30 100644 --- a/src/disk.c +++ b/src/disk.c @@ -170,7 +170,7 @@ static int disk_config(const char *key, const char *value) { ignorelist_set_invert(ignorelist, invert); } else if (strcasecmp("UseBSDName", key) == 0) { #if HAVE_IOKIT_IOKITLIB_H - use_bsd_name = IS_TRUE(value) ? 1 : 0; + use_bsd_name = IS_TRUE(value); #else WARNING("disk plugin: The \"UseBSDName\" option is only supported " "on Mach / Mac OS X and will be ignored."); @@ -817,13 +817,13 @@ static int disk_read(void) { ds->write_time = write_time; if (read_merged || write_merged) - ds->has_merged = 1; + ds->has_merged = true; if (in_progress) - ds->has_in_progress = 1; + ds->has_in_progress = true; if (io_time) - ds->has_io_time = 1; + ds->has_io_time = true; } /* if (is_disk) */ diff --git a/src/dpdkevents.c b/src/dpdkevents.c index 28156b0b..6fd642ba 100644 --- a/src/dpdkevents.c +++ b/src/dpdkevents.c @@ -185,8 +185,8 @@ static void dpdk_events_default_config(void) { /* Link Status */ ec->config.link_status.enabled = 1; ec->config.link_status.enabled_port_mask = ~0; - ec->config.link_status.send_updated = 1; - ec->config.link_status.notify = 0; + ec->config.link_status.send_updated = true; + ec->config.link_status.notify = false; for (int i = 0; i < RTE_MAX_ETHPORTS; i++) { ec->config.link_status.port_name[i][0] = 0; @@ -194,8 +194,8 @@ static void dpdk_events_default_config(void) { /* Keep Alive */ ec->config.keep_alive.enabled = 1; - ec->config.keep_alive.send_updated = 1; - ec->config.keep_alive.notify = 0; + ec->config.keep_alive.send_updated = true; + ec->config.keep_alive.notify = false; /* by default enable 128 cores */ memset(&ec->config.keep_alive.lcore_mask, 1, sizeof(ec->config.keep_alive.lcore_mask)); diff --git a/src/fhcount.c b/src/fhcount.c index 05506651..9bcb9115 100644 --- a/src/fhcount.c +++ b/src/fhcount.c @@ -33,17 +33,17 @@ static int fhcount_config(const char *key, const char *value) { if (strcasecmp(key, "ValuesAbsolute") == 0) { if (IS_TRUE(value)) { - values_absolute = 1; + values_absolute = true; } else { - values_absolute = 0; + values_absolute = false; } ret = 0; } else if (strcasecmp(key, "ValuesPercentage") == 0) { if (IS_TRUE(value)) { - values_percentage = 1; + values_percentage = true; } else { - values_percentage = 0; + values_percentage = false; } ret = 0; diff --git a/src/grpc.cc b/src/grpc.cc index fd2891f4..17168ec2 100644 --- a/src/grpc.cc +++ b/src/grpc.cc @@ -664,7 +664,7 @@ static int c_grpc_config_listen(oconfig_item_t *ci) { } pkcp.cert_chain = read_file(cert); } else if (!strcasecmp("VerifyPeer", child->key)) { - bool verify = 0; + bool verify = false; if (cf_util_get_boolean(child, &verify)) { return -1; } diff --git a/src/hugepages.c b/src/hugepages.c index adfc5bb4..dd897356 100644 --- a/src/hugepages.c +++ b/src/hugepages.c @@ -102,20 +102,20 @@ static void submit_hp(const struct entry_info *info) { if (g_values_pages) { sstrncpy(vl.type, "vmpage_number", sizeof(vl.type)); - plugin_dispatch_multivalue(&vl, /* store_percentage = */ 0, DS_TYPE_GAUGE, - "free", free, "used", used, NULL); + plugin_dispatch_multivalue(&vl, /* store_percentage = */ false, + DS_TYPE_GAUGE, "free", free, "used", used, NULL); } if (g_values_bytes) { gauge_t page_size = (gauge_t)(1024 * info->page_size_kb); sstrncpy(vl.type, "memory", sizeof(vl.type)); - plugin_dispatch_multivalue(&vl, /* store_percentage = */ 0, DS_TYPE_GAUGE, - "free", free * page_size, "used", + plugin_dispatch_multivalue(&vl, /* store_percentage = */ false, + DS_TYPE_GAUGE, "free", free * page_size, "used", used * page_size, NULL); } if (g_values_percent) { sstrncpy(vl.type, "percent", sizeof(vl.type)); - plugin_dispatch_multivalue(&vl, /* store_percentage = */ 1, DS_TYPE_GAUGE, - "free", free, "used", used, NULL); + plugin_dispatch_multivalue(&vl, /* store_percentage = */ true, + DS_TYPE_GAUGE, "free", free, "used", used, NULL); } } diff --git a/src/interface.c b/src/interface.c index 39ca8803..3e2b2cd5 100644 --- a/src/interface.c +++ b/src/interface.c @@ -117,7 +117,7 @@ static int interface_config(const char *key, const char *value) { else if (strcasecmp(key, "UniqueName") == 0) { #ifdef HAVE_LIBKSTAT if (IS_TRUE(value)) - unique_name = 1; + unique_name = true; #else WARNING("interface plugin: the \"UniqueName\" option is only valid on " "Solaris."); diff --git a/src/ipmi.c b/src/ipmi.c index 64651a24..2475278a 100644 --- a/src/ipmi.c +++ b/src/ipmi.c @@ -884,7 +884,7 @@ static void domain_connection_change_handler(ipmi_domain_t *domain, int err, plugin_dispatch_notification(&n); } - st->connected = 0; + st->connected = false; return; } @@ -896,7 +896,7 @@ static void domain_connection_change_handler(ipmi_domain_t *domain, int err, plugin_dispatch_notification(&n); } - st->connected = 1; + st->connected = true; int status = ipmi_domain_add_entity_update_handler( domain, domain_entity_update_handler, /* user data = */ st); @@ -965,11 +965,11 @@ static void *c_ipmi_thread_main(void *user_data) { int status = c_ipmi_thread_init(st); if (status != 0) { ERROR("ipmi plugin: c_ipmi_thread_init failed."); - st->active = 0; + st->active = false; return (void *)-1; } - while (st->active != 0) { + while (st->active) { struct timeval tv = {1, 0}; os_handler->perform_one_op(os_handler, &tv); } @@ -1158,12 +1158,12 @@ static int c_ipmi_config(oconfig_item_t *ci) { static int c_ipmi_read(user_data_t *user_data) { c_ipmi_instance_t *st = user_data->data; - if (st->active == 0) { + if (st->active == false) { INFO("ipmi plugin: c_ipmi_read: I'm not active, returning false."); return -1; } - if (st->connected == 0) + if (st->connected == false) return 0; sensor_list_read_all(st); @@ -1234,14 +1234,14 @@ static int c_ipmi_init(void) { } st->init_in_progress = cycles; - st->active = 1; + st->active = true; status = plugin_thread_create(&st->thread_id, /* attr = */ NULL, c_ipmi_thread_main, /* user data = */ (void *)st, "ipmi"); if (status != 0) { - st->active = 0; + st->active = false; st->thread_id = (pthread_t){0}; plugin_unregister_read(callback_name); @@ -1263,7 +1263,7 @@ static int c_ipmi_shutdown(void) { c_ipmi_instance_t *next = st->next; st->next = NULL; - st->active = 0; + st->active = false; if (!pthread_equal(st->thread_id, (pthread_t){0})) { pthread_join(st->thread_id, NULL); diff --git a/src/libcollectdclient/network_buffer.c b/src/libcollectdclient/network_buffer.c index 2332e3ec..373dd2b7 100644 --- a/src/libcollectdclient/network_buffer.c +++ b/src/libcollectdclient/network_buffer.c @@ -130,26 +130,26 @@ static bool have_gcrypt(void) /* {{{ */ if (!need_init) return result; - need_init = 0; + need_init = false; #if HAVE_GCRYPT_H #if GCRYPT_VERSION_NUMBER < 0x010600 if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread)) - return 0; + return false; #endif if (!gcry_check_version(GCRYPT_VERSION)) - return 0; + return false; if (!gcry_control(GCRYCTL_INIT_SECMEM, 32768, 0)) - return 0; + return false; gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); - result = 1; - return 1; + result = true; + return true; #else - return 0; + return false; #endif } /* }}} bool have_gcrypt */ diff --git a/src/load.c b/src/load.c index 4bc93d5e..858d9bea 100644 --- a/src/load.c +++ b/src/load.c @@ -63,7 +63,7 @@ static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); static int load_config(const char *key, const char *value) { if (strcasecmp(key, "ReportRelative") == 0) #ifdef _SC_NPROCESSORS_ONLN - report_relative_load = IS_TRUE(value) ? 1 : 0; + report_relative_load = IS_TRUE(value); #else WARNING("load plugin: The \"ReportRelative\" configuration " "is not available, because I can't determine the " diff --git a/src/log_logstash.c b/src/log_logstash.c index 134df6e0..2553a28c 100644 --- a/src/log_logstash.c +++ b/src/log_logstash.c @@ -75,7 +75,7 @@ static int log_logstash_config(const char *key, const char *value) { static void log_logstash_print(yajl_gen g, int severity, cdtime_t timestamp_time) { FILE *fh; - bool do_close = 0; + bool do_close = false; struct tm timestamp_tm; char timestamp_str[64]; const unsigned char *buf; @@ -150,13 +150,13 @@ static void log_logstash_print(yajl_gen g, int severity, fh = stderr; } else if (strcasecmp(log_file, "stdout") == 0) { fh = stdout; - do_close = 0; + do_close = false; } else if (strcasecmp(log_file, "stderr") == 0) { fh = stderr; - do_close = 0; + do_close = false; } else { fh = fopen(log_file, "a"); - do_close = 1; + do_close = true; } if (fh == NULL) { diff --git a/src/logfile.c b/src/logfile.c index 3917aa8f..ee2ed5ce 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -77,7 +77,7 @@ static int logfile_config(const char *key, const char *value) { static void logfile_print(const char *msg, int severity, cdtime_t timestamp_time) { FILE *fh; - bool do_close = 0; + bool do_close = false; char timestamp_str[64]; char level_str[16] = ""; @@ -122,7 +122,7 @@ static void logfile_print(const char *msg, int severity, fh = stdout; else { fh = fopen(log_file, "a"); - do_close = 1; + do_close = true; } if (fh == NULL) { diff --git a/src/lpar.c b/src/lpar.c index 77e6d087..df18b525 100644 --- a/src/lpar.c +++ b/src/lpar.c @@ -52,14 +52,14 @@ static perfstat_partition_total_t lparstats_old; static int lpar_config(const char *key, const char *value) { if (strcasecmp("CpuPoolStats", key) == 0) { if (IS_TRUE(value)) - pool_stats = 1; + pool_stats = true; else - pool_stats = 0; + pool_stats = false; } else if (strcasecmp("ReportBySerial", key) == 0) { if (IS_TRUE(value)) - report_by_serial = 1; + report_by_serial = true; else - report_by_serial = 0; + report_by_serial = false; } else { return -1; } @@ -84,14 +84,14 @@ static int lpar_init(void) { #if PERFSTAT_SUPPORTS_DONATION if (!lparstats_old.type.b.shared_enabled && lparstats_old.type.b.donate_enabled) { - donate_flag = 1; + donate_flag = true; } #endif if (pool_stats && !lparstats_old.type.b.pool_util_authority) { WARNING("lpar plugin: This partition does not have pool authority. " "Disabling CPU pool statistics collection."); - pool_stats = 0; + pool_stats = false; } return 0; diff --git a/src/match_regex.c b/src/match_regex.c index 84934a6c..ed1e3295 100644 --- a/src/match_regex.c +++ b/src/match_regex.c @@ -245,7 +245,7 @@ static int mr_create(const oconfig_item_t *ci, void **user_data) /* {{{ */ return -ENOMEM; } - m->invert = 0; + m->invert = false; status = 0; for (int i = 0; i < ci->children_num; i++) { diff --git a/src/mcelog.c b/src/mcelog.c index 5692a000..4e514004 100644 --- a/src/mcelog.c +++ b/src/mcelog.c @@ -90,7 +90,7 @@ static int socket_reinit(socket_adapter_t *self); static int socket_receive(socket_adapter_t *self, FILE **p_file); static mcelog_config_t g_mcelog_config = { - .logfile = "/var/log/mcelog", .persist = 0, + .logfile = "/var/log/mcelog", .persist = false, }; static socket_adapter_t socket_adapter = { diff --git a/src/memcached.c b/src/memcached.c index 45796146..11df999d 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -702,7 +702,7 @@ static int config_add_instance(oconfig_item_t *ci) { int status = 0; /* Disable automatic generation of default instance in the init callback. */ - memcached_have_instances = 1; + memcached_have_instances = true; memcached_t *st = calloc(1, sizeof(*st)); if (st == NULL) { @@ -797,7 +797,7 @@ static int memcached_init(void) { int status = memcached_add_read_callback(st); if (status == 0) - memcached_have_instances = 1; + memcached_have_instances = true; return status; } /* int memcached_init */ diff --git a/src/memory.c b/src/memory.c index 366ca1c8..cc95496a 100644 --- a/src/memory.c +++ b/src/memory.c @@ -163,9 +163,9 @@ static int memory_init(void) { #define MEMORY_SUBMIT(...) \ do { \ if (values_absolute) \ - plugin_dispatch_multivalue(vl, 0, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \ + plugin_dispatch_multivalue(vl, false, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \ if (values_percentage) \ - plugin_dispatch_multivalue(vl, 1, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \ + plugin_dispatch_multivalue(vl, true, DS_TYPE_GAUGE, __VA_ARGS__, NULL); \ } while (0) static int memory_read_internal(value_list_t *vl) { @@ -268,7 +268,7 @@ static int memory_read_internal(value_list_t *vl) { char *fields[8]; int numfields; - bool detailed_slab_info = 0; + bool detailed_slab_info = false; gauge_t mem_total = 0; gauge_t mem_used = 0; @@ -299,10 +299,10 @@ static int memory_read_internal(value_list_t *vl) { val = &mem_slab_total; else if (strncasecmp(buffer, "SReclaimable:", 13) == 0) { val = &mem_slab_reclaimable; - detailed_slab_info = 1; + detailed_slab_info = true; } else if (strncasecmp(buffer, "SUnreclaim:", 11) == 0) { val = &mem_slab_unreclaimable; - detailed_slab_info = 1; + detailed_slab_info = true; } else continue; diff --git a/src/modbus.c b/src/modbus.c index 2f1a6820..2b5e6877 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -332,7 +332,7 @@ static int mb_init_connection(mb_host_t *host) /* {{{ */ return status; } - host->is_connected = 1; + host->is_connected = true; return 0; } /* }}} int mb_init_connection */ /* #endif LEGACY_LIBMODBUS */ @@ -465,7 +465,7 @@ static int mb_read_data(mb_host_t *host, mb_slave_t *slave, /* {{{ */ if (status != 0) { ERROR("Modbus plugin: mb_init_connection (%s/%s) failed. ", host->host, host->node); - host->is_connected = 0; + host->is_connected = false; host->connection = NULL; return -1; } diff --git a/src/mqtt.c b/src/mqtt.c index 097302ad..3d89f407 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -141,7 +141,7 @@ static void mqtt_free(mqtt_client_conf_t *conf) { if (conf->connected) (void)mosquitto_disconnect(conf->mosq); - conf->connected = 0; + conf->connected = false; (void)mosquitto_destroy(conf->mosq); sfree(conf->host); @@ -252,7 +252,7 @@ static int mqtt_reconnect(mqtt_client_conf_t *conf) { return -1; } - conf->connected = 1; + conf->connected = true; c_release(LOG_INFO, &conf->complaint_cantpublish, "mqtt plugin: successfully reconnected to broker \"%s:%d\"", @@ -366,7 +366,7 @@ static int mqtt_connect(mqtt_client_conf_t *conf) { } } - conf->connected = 1; + conf->connected = true; return 0; } /* mqtt_connect */ @@ -393,14 +393,14 @@ static void *subscribers_thread(void *arg) { /* max_packets = */ 100); #endif if (status == MOSQ_ERR_CONN_LOST) { - conf->connected = 0; + conf->connected = false; continue; } else if (status != MOSQ_ERR_SUCCESS) { ERROR("mqtt plugin: mosquitto_loop failed: %s", mosquitto_strerror(status)); mosquitto_destroy(conf->mosq); conf->mosq = NULL; - conf->connected = 0; + conf->connected = false; continue; } @@ -438,7 +438,7 @@ static int publish(mqtt_client_conf_t *conf, char const *topic, /* Mark our connection "down" regardless of the error as a safety * measure; we will try to reconnect the next time we have to publish a * message */ - conf->connected = 0; + conf->connected = false; mosquitto_disconnect(conf->mosq); pthread_mutex_unlock(&conf->lock); @@ -532,7 +532,7 @@ static int mqtt_config_publisher(oconfig_item_t *ci) { ERROR("mqtt plugin: calloc failed."); return -1; } - conf->publish = 1; + conf->publish = true; conf->name = NULL; status = cf_util_get_string(ci, &conf->name); @@ -546,7 +546,7 @@ static int mqtt_config_publisher(oconfig_item_t *ci) { conf->client_id = NULL; conf->qos = 0; conf->topic_prefix = strdup(MQTT_DEFAULT_TOPIC_PREFIX); - conf->store_rates = 1; + conf->store_rates = true; status = pthread_mutex_init(&conf->lock, NULL); if (status != 0) { @@ -631,7 +631,7 @@ static int mqtt_config_subscriber(oconfig_item_t *ci) { ERROR("mqtt plugin: calloc failed."); return -1; } - conf->publish = 0; + conf->publish = false; conf->name = NULL; status = cf_util_get_string(ci, &conf->name); @@ -645,7 +645,7 @@ static int mqtt_config_subscriber(oconfig_item_t *ci) { conf->client_id = NULL; conf->qos = 2; conf->topic = strdup(MQTT_DEFAULT_TOPIC); - conf->clean_session = 1; + conf->clean_session = true; status = pthread_mutex_init(&conf->lock, NULL); if (status != 0) { diff --git a/src/mysql.c b/src/mysql.c index 1396e954..40707be3 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -147,8 +147,8 @@ static int mysql_config_database(oconfig_item_t *ci) /* {{{ */ db->timeout = 0; /* trigger a notification, if it's not running */ - db->slave_io_running = 1; - db->slave_sql_running = 1; + db->slave_io_running = true; + db->slave_sql_running = true; status = cf_util_get_string(ci, &db->instance); if (status != 0) { @@ -268,7 +268,7 @@ static MYSQL *getconnection(mysql_database_t *db) { WARNING("mysql plugin: Lost connection to instance \"%s\": %s", db->instance, mysql_error(db->con)); } - db->is_connected = 0; + db->is_connected = false; /* Close the old connection before initializing a new one. */ if (db->con != NULL) { @@ -305,7 +305,7 @@ static MYSQL *getconnection(mysql_database_t *db) { mysql_get_host_info(db->con), (cipher != NULL) ? cipher : "", mysql_get_server_info(db->con), mysql_get_proto_info(db->con)); - db->is_connected = 1; + db->is_connected = true; return db->con; } /* static MYSQL *getconnection (mysql_database_t *db) */ @@ -503,14 +503,14 @@ static int mysql_read_slave_stats(mysql_database_t *db, MYSQL *con) { snprintf(n.message, sizeof(n.message), "slave I/O thread not started or not connected to master"); plugin_dispatch_notification(&n); - db->slave_io_running = 0; + db->slave_io_running = false; } else if (((io != NULL) && (strcasecmp(io, "yes") == 0)) && (!db->slave_io_running)) { n.severity = NOTIF_OKAY; snprintf(n.message, sizeof(n.message), "slave I/O thread started and connected to master"); plugin_dispatch_notification(&n); - db->slave_io_running = 1; + db->slave_io_running = true; } if (((sql == NULL) || (strcasecmp(sql, "yes") != 0)) && @@ -518,13 +518,13 @@ static int mysql_read_slave_stats(mysql_database_t *db, MYSQL *con) { n.severity = NOTIF_WARNING; snprintf(n.message, sizeof(n.message), "slave SQL thread not started"); plugin_dispatch_notification(&n); - db->slave_sql_running = 0; + db->slave_sql_running = false; } else if (((sql != NULL) && (strcasecmp(sql, "yes") == 0)) && (!db->slave_sql_running)) { n.severity = NOTIF_OKAY; snprintf(n.message, sizeof(n.message), "slave SQL thread started"); plugin_dispatch_notification(&n); - db->slave_sql_running = 1; + db->slave_sql_running = true; } } diff --git a/src/netapp.c b/src/netapp.c index 90b3791c..281764c7 100644 --- a/src/netapp.c +++ b/src/netapp.c @@ -2842,11 +2842,11 @@ static int cna_register_host(host_config_t *host) /* {{{ */ static int cna_config_host(host_config_t *host, /* {{{ */ const oconfig_item_t *ci) { oconfig_item_t *item; - bool is_vfiler = 0; + bool is_vfiler = false; int status; if (!strcasecmp(ci->key, "VFiler")) - is_vfiler = 1; + is_vfiler = true; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { WARNING("netapp plugin: \"%s\" needs exactly one string argument. Ignoring " diff --git a/src/netlink.c b/src/netlink.c index a9d324a3..67fbe551 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -449,7 +449,7 @@ static int qos_filter_cb(const struct nlmsghdr *nlh, void *args) { const char *tc_type; char tc_inst[DATA_MAX_NAME_LEN]; - bool stats_submitted = 0; + bool stats_submitted = false; if (nlh->nlmsg_type == RTM_NEWQDISC) tc_type = "qdisc"; @@ -539,7 +539,7 @@ static int qos_filter_cb(const struct nlmsghdr *nlh, void *args) { if (q_stats.bs != NULL || q_stats.qs != NULL) { char type_instance[DATA_MAX_NAME_LEN]; - stats_submitted = 1; + stats_submitted = true; snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type, tc_inst); diff --git a/src/network.c b/src/network.c index 270bed29..ab5ff299 100644 --- a/src/network.c +++ b/src/network.c @@ -1924,7 +1924,7 @@ static int sockent_client_connect(sockent_t *se) /* {{{ */ struct sockent_client *client; struct addrinfo *ai_list; int status; - bool reconnect = 0; + bool reconnect = false; cdtime_t now; if ((se == NULL) || (se->type != SOCKENT_TYPE_CLIENT)) @@ -1938,7 +1938,7 @@ static int sockent_client_connect(sockent_t *se) /* {{{ */ "next_resolve_reconnect = %lf", CDTIME_T_TO_DOUBLE(client->resolve_interval), CDTIME_T_TO_DOUBLE(client->next_resolve_reconnect)); - reconnect = 1; + reconnect = true; } if (client->fd >= 0 && !reconnect) /* already connected and not stale*/ @@ -3102,7 +3102,7 @@ static int network_init(void) { * nothing more to do (for now, that is). */ if (have_init) return 0; - have_init = 1; + have_init = true; if (network_config_stats) plugin_register_read("network", network_stats_read); diff --git a/src/ntpd.c b/src/ntpd.c index 1827dc3e..8976866d 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -272,14 +272,14 @@ static int ntpd_config(const char *key, const char *value) { sstrncpy(ntpd_port, value, sizeof(ntpd_port)); } else if (strcasecmp(key, "ReverseLookups") == 0) { if (IS_TRUE(value)) - do_reverse_lookups = 1; + do_reverse_lookups = true; else - do_reverse_lookups = 0; + do_reverse_lookups = false; } else if (strcasecmp(key, "IncludeUnitID") == 0) { if (IS_TRUE(value)) - include_unit_id = 1; + include_unit_id = true; else - include_unit_id = 0; + include_unit_id = false; } else { return -1; } diff --git a/src/onewire.c b/src/onewire.c index 1803d264..37112ad7 100644 --- a/src/onewire.c +++ b/src/onewire.c @@ -171,7 +171,7 @@ static int direct_list_insert(const char *config) { direct_list_element_free(element); return 1; } - regex_direct_initialized = 1; + regex_direct_initialized = true; DEBUG("onewire plugin: Compiled regex!!"); } @@ -246,7 +246,7 @@ static int cow_load_config(const char *key, const char *value) { } } else { DEBUG("onewire plugin: %s is a direct access", value); - direct_access = 1; + direct_access = true; } } else if (strcasecmp(key, "IgnoreSelected") == 0) { ignorelist_set_invert(sensor_list, 1); diff --git a/src/openldap.c b/src/openldap.c index c601d9ca..3897cd16 100644 --- a/src/openldap.c +++ b/src/openldap.c @@ -105,12 +105,12 @@ static int cldap_init_host(cldap_t *st) /* {{{ */ if (st->cacert != NULL) ldap_set_option(st->ld, LDAP_OPT_X_TLS_CACERTFILE, st->cacert); - if (st->verifyhost == 0) { + if (st->verifyhost == false) { int never = LDAP_OPT_X_TLS_NEVER; ldap_set_option(st->ld, LDAP_OPT_X_TLS_REQUIRE_CERT, &never); } - if (st->starttls != 0) { + if (st->starttls) { rc = ldap_start_tls_s(st->ld, NULL, NULL); if (rc != LDAP_SUCCESS) { ERROR("openldap plugin: Failed to start tls on %s: %s", st->url, @@ -397,9 +397,9 @@ static int cldap_config_add(oconfig_item_t *ci) /* {{{ */ return status; } - st->starttls = 0; + st->starttls = false; st->timeout = (long)CDTIME_T_TO_TIME_T(plugin_get_interval()); - st->verifyhost = 1; + st->verifyhost = true; st->version = LDAP_VERSION3; for (int i = 0; i < ci->children_num; i++) { diff --git a/src/openvpn.c b/src/openvpn.c index a80c09fb..193a9b43 100644 --- a/src/openvpn.c +++ b/src/openvpn.c @@ -247,7 +247,7 @@ static int multi1_read(const char *name, FILE *fh) { char *fields[10]; const int max_fields = STATIC_ARRAY_SIZE(fields); long long sum_users = 0; - bool found_header = 0; + bool found_header = false; /* read the file until the "ROUTING TABLE" line is found (no more info after) */ @@ -256,12 +256,12 @@ static int multi1_read(const char *name, FILE *fh) { break; if (strcmp(buffer, V1HEADER) == 0) { - found_header = 1; + found_header = true; continue; } /* skip the first lines until the client list section is found */ - if (found_header == 0) + if (found_header == false) /* we can't start reading data until this string is found */ continue; @@ -292,7 +292,7 @@ static int multi1_read(const char *name, FILE *fh) { if (ferror(fh)) return -1; - if (found_header == 0) { + if (found_header == false) { NOTICE("openvpn plugin: Unknown file format in instance %s, please " "report this as bug. Make sure to include " "your status file, so the plugin can " @@ -320,7 +320,7 @@ static int multi2_read(const char *name, FILE *fh) { const int max_fields = STATIC_ARRAY_SIZE(fields); long long sum_users = 0; - bool found_header = 0; + bool found_header = false; int idx_cname = 0; int idx_bytes_recv = 0; int idx_bytes_sent = 0; @@ -330,7 +330,7 @@ static int multi2_read(const char *name, FILE *fh) { int fields_num = openvpn_strsplit(buffer, fields, max_fields); /* Try to find section header */ - if (found_header == 0) { + if (found_header == false) { if (fields_num < 2) continue; if (strcmp(fields[0], "HEADER") != 0) @@ -358,7 +358,7 @@ static int multi2_read(const char *name, FILE *fh) { /* Data row has 1 field ("HEADER") less than header row */ columns = fields_num - 1; - found_header = 1; + found_header = true; continue; } @@ -404,7 +404,7 @@ static int multi2_read(const char *name, FILE *fh) { if (ferror(fh)) return -1; - if (found_header == 0) { + if (found_header == false) { NOTICE("openvpn plugin: Unknown file format in instance %s, please " "report this as bug. Make sure to include " "your status file, so the plugin can " @@ -519,29 +519,29 @@ static int openvpn_config(const char *key, const char *value) { (strcasecmp("Compression", key) == 0)) /* old, deprecated name */ { if (IS_FALSE(value)) - collect_compression = 0; + collect_compression = false; else - collect_compression = 1; + collect_compression = true; } /* if (strcasecmp ("CollectCompression", key) == 0) */ else if (strcasecmp("ImprovedNamingSchema", key) == 0) { if (IS_TRUE(value)) { DEBUG("openvpn plugin: using the new naming schema"); - new_naming_schema = 1; + new_naming_schema = true; } else { - new_naming_schema = 0; + new_naming_schema = false; } } /* if (strcasecmp ("ImprovedNamingSchema", key) == 0) */ else if (strcasecmp("CollectUserCount", key) == 0) { if (IS_TRUE(value)) - collect_user_count = 1; + collect_user_count = true; else - collect_user_count = 0; + collect_user_count = false; } /* if (strcasecmp("CollectUserCount", key) == 0) */ else if (strcasecmp("CollectIndividualUsers", key) == 0) { if (IS_FALSE(value)) - collect_individual_users = 0; + collect_individual_users = false; else - collect_individual_users = 1; + collect_individual_users = true; } /* if (strcasecmp("CollectIndividualUsers", key) == 0) */ else { return -1; diff --git a/src/ovs_events.c b/src/ovs_events.c index 10a0f43e..ba3238b6 100644 --- a/src/ovs_events.c +++ b/src/ovs_events.c @@ -89,7 +89,7 @@ typedef struct ovs_events_ctx_s ovs_events_ctx_t; */ static ovs_events_ctx_t ovs_events_ctx = { .mutex = PTHREAD_MUTEX_INITIALIZER, - .config = {.send_notification = 1, /* send notification by default */ + .config = {.send_notification = true, /* send notification by default */ .ovs_db_node = "localhost", /* use default OVS DB node */ .ovs_db_serv = "6640"} /* use default OVS DB service */ }; @@ -231,7 +231,7 @@ static int ovs_events_config_get_interfaces(const oconfig_item_t *ci) { * in allocated memory. Returns negative value in case of error. */ static int ovs_events_plugin_config(oconfig_item_t *ci) { - bool dispatch_values = 0; + bool dispatch_values = false; for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp("SendNotification", child->key) == 0) { @@ -577,7 +577,7 @@ static void ovs_events_conn_initialize(ovs_db_t *pdb) { return; } } - OVS_EVENTS_CTX_LOCK { ovs_events_ctx.is_db_available = 1; } + OVS_EVENTS_CTX_LOCK { ovs_events_ctx.is_db_available = true; } DEBUG(OVS_EVENTS_PLUGIN ": OVS DB connection has been initialized"); } @@ -587,12 +587,12 @@ static void ovs_events_conn_terminate() { if (ovs_events_ctx.config.send_notification) ovs_events_dispatch_terminate_notification(msg); WARNING(OVS_EVENTS_PLUGIN ": %s", msg); - OVS_EVENTS_CTX_LOCK { ovs_events_ctx.is_db_available = 0; } + OVS_EVENTS_CTX_LOCK { ovs_events_ctx.is_db_available = false; } } /* Read OVS DB interface link status callback */ static int ovs_events_plugin_read(__attribute__((unused)) user_data_t *u) { - bool is_connected = 0; + bool is_connected = false; OVS_EVENTS_CTX_LOCK { is_connected = ovs_events_ctx.is_db_available; } if (is_connected) if (ovs_db_send_request(ovs_events_ctx.ovs_db, "transact", diff --git a/src/perl.c b/src/perl.c index 8c57f576..6683b4cc 100644 --- a/src/perl.c +++ b/src/perl.c @@ -989,7 +989,7 @@ static int call_pv_locked(pTHX_ const char *sub_name) { return 0; old_running = t->running; - t->running = 1; + t->running = true; if (t->shutdown) { t->running = old_running; @@ -1189,7 +1189,7 @@ static void c_ithread_destroy(c_ithread_t *ithread) { /* Mark as running to avoid deadlock: c_ithread_destroy -> log_debug -> perl_log() */ - ithread->running = 1; + ithread->running = true; log_debug("Shutting down Perl interpreter %p...", aTHX); #if COLLECT_DEBUG @@ -1275,8 +1275,8 @@ static c_ithread_t *c_ithread_create(PerlInterpreter *base) { } t->pthread = pthread_self(); - t->running = 0; - t->shutdown = 0; + t->running = false; + t->shutdown = false; perl_threads->tail = t; pthread_setspecific(perl_thr_key, (const void *)t); @@ -2276,7 +2276,7 @@ static int perl_shutdown(void) { * the thread as this will free the memory */ t = t->prev; - thr->shutdown = 1; + thr->shutdown = true; if (thr->running) { /* Give some time to thread to exit from Perl interpreter */ WARNING("perl shutdown: Thread is running inside Perl. Waiting."); diff --git a/src/pf.c b/src/pf.c index aa2a53a4..88a4c2d0 100644 --- a/src/pf.c +++ b/src/pf.c @@ -103,19 +103,19 @@ static int pf_read(void) { for (int i = 0; i < PFRES_MAX; i++) pf_submit("pf_counters", pf_reasons[i], state.counters[i], - /* is gauge = */ 0); + /* is gauge = */ false); for (int i = 0; i < LCNT_MAX; i++) pf_submit("pf_limits", pf_lcounters[i], state.lcounters[i], - /* is gauge = */ 0); + /* is gauge = */ false); for (int i = 0; i < FCNT_MAX; i++) pf_submit("pf_state", pf_fcounters[i], state.fcounters[i], - /* is gauge = */ 0); + /* is gauge = */ false); for (int i = 0; i < SCNT_MAX; i++) pf_submit("pf_source", pf_scounters[i], state.scounters[i], - /* is gauge = */ 0); + /* is gauge = */ false); pf_submit("pf_states", "current", (uint32_t)state.states, - /* is gauge = */ 1); + /* is gauge = */ true); return 0; } /* int pf_read */ diff --git a/src/pinba.c b/src/pinba.c index 9620f1b8..e82ac0e5 100644 --- a/src/pinba.c +++ b/src/pinba.c @@ -490,7 +490,7 @@ static void *collector_thread(void *arg) /* {{{ */ receive_loop(); memset(&collector_thread_id, 0, sizeof(collector_thread_id)); - collector_thread_running = 0; + collector_thread_running = false; pthread_exit(NULL); return NULL; } /* }}} void *collector_thread */ @@ -585,7 +585,7 @@ static int plugin_init(void) /* {{{ */ ERROR("pinba plugin: pthread_create(3) failed: %s", STRERRNO); return -1; } - collector_thread_running = 1; + collector_thread_running = true; return 0; } /* }}} */ @@ -596,15 +596,15 @@ static int plugin_shutdown(void) /* {{{ */ int status; DEBUG("pinba plugin: Shutting down collector thread."); - collector_thread_do_shutdown = 1; + collector_thread_do_shutdown = true; status = pthread_join(collector_thread_id, /* retval = */ NULL); if (status != 0) { ERROR("pinba plugin: pthread_join(3) failed: %s", STRERROR(status)); } - collector_thread_running = 0; - collector_thread_do_shutdown = 0; + collector_thread_running = false; + collector_thread_do_shutdown = false; } /* if (collector_thread_running) */ return 0; diff --git a/src/ping.c b/src/ping.c index 89e407b2..565ae99c 100644 --- a/src/ping.c +++ b/src/ping.c @@ -298,7 +298,7 @@ static void *ping_thread(void *arg) /* {{{ */ pthread_mutex_lock(&ping_lock); while (ping_thread_loop > 0) { - bool send_successful = 0; + bool send_successful = false; if (gettimeofday(&tv_begin, NULL) < 0) { ERROR("ping plugin: gettimeofday failed: %s", STRERRNO); @@ -314,7 +314,7 @@ static void *ping_thread(void *arg) /* {{{ */ ping_get_error(pingobj)); } else { c_release(LOG_NOTICE, &complaint, "ping plugin: ping_send succeeded."); - send_successful = 1; + send_successful = true; } pthread_mutex_lock(&ping_lock); diff --git a/src/postgresql.c b/src/postgresql.c index 803b63be..f626b579 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -348,10 +348,10 @@ static int c_psql_connect(c_psql_database_t *db) { } /* c_psql_connect */ static int c_psql_check_connection(c_psql_database_t *db) { - bool init = 0; + bool init = false; if (!db->conn) { - init = 1; + init = true; /* trigger c_release() */ if (0 == db->conn_complaint.interval) @@ -936,7 +936,7 @@ static int c_psql_flush(cdtime_t timeout, } /* c_psql_flush */ static int c_psql_shutdown(void) { - bool had_flush = 0; + bool had_flush = false; plugin_unregister_read_group("postgresql"); @@ -949,7 +949,7 @@ static int c_psql_shutdown(void) { if (!had_flush) { plugin_unregister_flush("postgresql"); - had_flush = 1; + had_flush = true; } plugin_unregister_flush(cb_name); @@ -1097,7 +1097,7 @@ static int c_psql_config_writer(oconfig_item_t *ci) { writer->name = sstrdup(ci->values[0].value.string); writer->statement = NULL; - writer->store_rates = 1; + writer->store_rates = true; for (int i = 0; i < ci->children_num; ++i) { oconfig_item_t *c = ci->children + i; @@ -1221,7 +1221,7 @@ static int c_psql_config_database(oconfig_item_t *ci) { if (!have_flush) { /* flush all */ plugin_register_flush("postgresql", c_psql_flush, /* user data = */ NULL); - have_flush = 1; + have_flush = true; } /* flush this connection only */ diff --git a/src/processes.c b/src/processes.c index d283d3e1..2a4ce1f7 100644 --- a/src/processes.c +++ b/src/processes.c @@ -1252,38 +1252,38 @@ static int ps_delay(process_entry_t *ps) { #endif static void ps_fill_details(const procstat_t *ps, process_entry_t *entry) { - if (entry->has_io == 0) { + if (entry->has_io == false) { ps_read_io(entry); - entry->has_io = 1; + entry->has_io = true; } if (ps->report_ctx_switch) { - if (entry->has_cswitch == 0) { + if (entry->has_cswitch == false) { ps_read_tasks_status(entry); - entry->has_cswitch = 1; + entry->has_cswitch = true; } } if (ps->report_maps_num) { int num_maps; - if (entry->has_maps == 0 && (num_maps = ps_count_maps(entry->id)) > 0) { + if (entry->has_maps == false && (num_maps = ps_count_maps(entry->id)) > 0) { entry->num_maps = num_maps; } - entry->has_maps = 1; + entry->has_maps = true; } if (ps->report_fd_num) { int num_fd; - if (entry->has_fd == 0 && (num_fd = ps_count_fd(entry->id)) > 0) { + if (entry->has_fd == false && (num_fd = ps_count_fd(entry->id)) > 0) { entry->num_fd = num_fd; } - entry->has_fd = 1; + entry->has_fd = true; } #if HAVE_LIBTASKSTATS if (ps->report_delay && !entry->has_delay) { if (ps_delay(entry) == 0) { - entry->has_delay = 1; + entry->has_delay = true; } } #endif @@ -2632,7 +2632,7 @@ static int ps_read(void) { read_fork_rate(); #endif /* KERNEL_SOLARIS */ - want_init = 0; + want_init = false; return 0; } /* int ps_read */ diff --git a/src/rrdcached.c b/src/rrdcached.c index 3d7ae05a..c09e0485 100644 --- a/src/rrdcached.c +++ b/src/rrdcached.c @@ -284,7 +284,7 @@ static int try_reconnect(void) { static int rc_read(void) { int status; rrdc_stats_t *head; - bool retried = 0; + bool retried = false; value_list_t vl = VALUE_LIST_INIT; vl.values = &(value_t){.gauge = NAN}; @@ -320,7 +320,7 @@ static int rc_read(void) { break; if (!retried) { - retried = 1; + retried = true; if (try_reconnect() == 0) continue; /* else: report the error and fail */ @@ -392,7 +392,7 @@ static int rc_write(const data_set_t *ds, const value_list_t *vl, char values[512]; char *values_array[2]; int status; - bool retried = 0; + bool retried = false; if (daemon_address == NULL) { ERROR("rrdcached plugin: daemon_address == NULL."); @@ -455,7 +455,7 @@ static int rc_write(const data_set_t *ds, const value_list_t *vl, break; if (!retried) { - retried = 1; + retried = true; if (try_reconnect() == 0) continue; /* else: report the error and fail */ @@ -474,7 +474,7 @@ static int rc_flush(__attribute__((unused)) cdtime_t timeout, /* {{{ */ __attribute__((unused)) user_data_t *ud) { char filename[PATH_MAX + 1]; int status; - bool retried = 0; + bool retried = false; if (identifier == NULL) return EINVAL; @@ -502,7 +502,7 @@ static int rc_flush(__attribute__((unused)) cdtime_t timeout, /* {{{ */ break; if (!retried) { - retried = 1; + retried = true; if (try_reconnect() == 0) continue; /* else: report the error and fail */ diff --git a/src/sensors.c b/src/sensors.c index 3969dc9a..ddd09d9b 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -225,7 +225,7 @@ static int sensors_config(const char *key, const char *value) { } #if (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500) else if (strcasecmp(key, "UseLabels") == 0) { - use_labels = IS_TRUE(value) ? 1 : 0; + use_labels = IS_TRUE(value); } #endif else { diff --git a/src/serial.c b/src/serial.c index 1b587ca3..8bbd94c0 100644 --- a/src/serial.c +++ b/src/serial.c @@ -59,7 +59,8 @@ static int serial_read(void) { while (fgets(buffer, sizeof(buffer), fh) != NULL) { derive_t rx = 0; derive_t tx = 0; - bool have_rx = 0, have_tx = 0; + bool have_rx = false; + bool have_tx = false; size_t len; char *fields[16]; @@ -87,10 +88,10 @@ static int serial_read(void) { if (strncmp(fields[i], "tx:", 3) == 0) { if (strtoderive(fields[i] + 3, &tx) == 0) - have_tx = 1; + have_tx = true; } else if (strncmp(fields[i], "rx:", 3) == 0) { if (strtoderive(fields[i] + 3, &rx) == 0) - have_rx = 1; + have_rx = true; } } diff --git a/src/snmp.c b/src/snmp.c index 923a5c4f..800c0505 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -399,8 +399,7 @@ static int csnmp_config_add_data(oconfig_item_t *ci) { DEBUG("snmp plugin: dd = { name = %s, type = %s, is_table = %s, values_len = " "%" PRIsz " }", - dd->name, dd->type, (dd->is_table != 0) ? "true" : "false", - dd->values_len); + dd->name, dd->type, (dd->is_table) ? "true" : "false", dd->values_len); if (data_head == NULL) data_head = dd; diff --git a/src/statsd.c b/src/statsd.c index 70c1a752..c7b472f1 100644 --- a/src/statsd.c +++ b/src/statsd.c @@ -666,7 +666,7 @@ static int statsd_init(void) /* {{{ */ return status; } } - network_thread_running = 1; + network_thread_running = true; pthread_mutex_unlock(&metrics_lock); @@ -876,11 +876,11 @@ static int statsd_shutdown(void) /* {{{ */ void *value; if (network_thread_running) { - network_thread_shutdown = 1; + network_thread_shutdown = true; pthread_kill(network_thread, SIGTERM); pthread_join(network_thread, /* retval = */ NULL); } - network_thread_running = 0; + network_thread_running = false; pthread_mutex_lock(&metrics_lock); diff --git a/src/swap.c b/src/swap.c index 2e0939d1..ede638a6 100644 --- a/src/swap.c +++ b/src/swap.c @@ -203,10 +203,10 @@ static void swap_submit_usage(char const *plugin_instance, /* {{{ */ sstrncpy(vl.type, "swap", sizeof(vl.type)); if (values_absolute) - plugin_dispatch_multivalue(&vl, 0, DS_TYPE_GAUGE, "used", used, "free", + plugin_dispatch_multivalue(&vl, false, DS_TYPE_GAUGE, "used", used, "free", free, other_name, other_value, NULL); if (values_percentage) - plugin_dispatch_multivalue(&vl, 1, DS_TYPE_GAUGE, "used", used, "free", + plugin_dispatch_multivalue(&vl, true, DS_TYPE_GAUGE, "used", used, "free", free, other_name, other_value, NULL); } /* }}} void swap_submit_usage */ @@ -335,7 +335,7 @@ static int swap_read_io(void) /* {{{ */ FILE *fh; char buffer[1024]; - bool old_kernel = 0; + bool old_kernel = false; uint8_t have_data = 0; derive_t swap_in = 0; @@ -349,7 +349,7 @@ static int swap_read_io(void) /* {{{ */ WARNING("swap: fopen: %s", STRERRNO); return -1; } else - old_kernel = 1; + old_kernel = true; } while (fgets(buffer, sizeof(buffer), fh) != NULL) { @@ -556,7 +556,7 @@ static int swap_read(void) /* {{{ */ return -1; } - /* If the "separate" option was specified (report_by_device == 1), all + /* If the "separate" option was specified (report_by_device == true) all * values have already been dispatched from within the loop. */ if (!report_by_device) swap_submit_usage(NULL, total - avail, avail, NULL, NAN); diff --git a/src/tail_csv.c b/src/tail_csv.c index 58e101f6..ff967052 100644 --- a/src/tail_csv.c +++ b/src/tail_csv.c @@ -123,14 +123,14 @@ static int tcsv_read_metric(instance_definition_t *id, metric_definition_t *md, static bool tcsv_check_index(ssize_t index, size_t fields_num, char const *name) { if (index < 0) - return 1; + return true; else if (((size_t)index) < fields_num) - return 1; + return true; ERROR("tail_csv plugin: Metric \"%s\": Request for index %zd when " "only %" PRIsz " fields are available.", name, index, fields_num); - return 0; + return false; } static int tcsv_read_buffer(instance_definition_t *id, char *buffer, diff --git a/src/target_replace.c b/src/target_replace.c index 4c8108e5..887507e1 100644 --- a/src/target_replace.c +++ b/src/target_replace.c @@ -306,7 +306,7 @@ static int tr_action_invoke(tr_action_t *act_head, /* {{{ */ DEBUG("target_replace plugin: tr_action_invoke: -- buffer = %s;", buffer); } /* for (act = act_head; act != NULL; act = act->next) */ - if ((may_be_empty == 0) && (buffer[0] == 0)) { + if ((may_be_empty == false) && (buffer[0] == 0)) { WARNING("Target `replace': Replacement resulted in an empty string, " "which is not allowed for this buffer (`host' or `plugin')."); return 0; @@ -470,13 +470,13 @@ static int tr_create(const oconfig_item_t *ci, void **user_data) /* {{{ */ if ((strcasecmp("Host", child->key) == 0) || (strcasecmp("Hostname", child->key) == 0)) status = tr_config_add_action(&data->host, child, - /* may be empty = */ 0); + /* may be empty = */ false); else if (strcasecmp("Plugin", child->key) == 0) status = tr_config_add_action(&data->plugin, child, - /* may be empty = */ 0); + /* may be empty = */ false); else if (strcasecmp("PluginInstance", child->key) == 0) status = tr_config_add_action(&data->plugin_instance, child, - /* may be empty = */ 1); + /* may be empty = */ true); #if 0 else if (strcasecmp ("Type", child->key) == 0) status = tr_config_add_action (&data->type, child, @@ -484,13 +484,13 @@ static int tr_create(const oconfig_item_t *ci, void **user_data) /* {{{ */ #endif else if (strcasecmp("TypeInstance", child->key) == 0) status = tr_config_add_action(&data->type_instance, child, - /* may be empty = */ 1); + /* may be empty = */ true); else if (strcasecmp("MetaData", child->key) == 0) status = tr_config_add_meta_action(&data->meta, child, - /* should delete = */ 0); + /* should delete = */ false); else if (strcasecmp("DeleteMetaData", child->key) == 0) status = tr_config_add_meta_action(&data->meta, child, - /* should delete = */ 1); + /* should delete = */ true); else { ERROR("Target `replace': The `%s' configuration option is not understood " "and will be ignored.", @@ -546,11 +546,11 @@ static int tr_invoke(const data_set_t *ds, value_list_t *vl, /* {{{ */ #define HANDLE_FIELD(f, e) \ if (data->f != NULL) \ tr_action_invoke(data->f, vl->f, sizeof(vl->f), e) - HANDLE_FIELD(host, 0); - HANDLE_FIELD(plugin, 0); - HANDLE_FIELD(plugin_instance, 1); - /* HANDLE_FIELD (type, 0); */ - HANDLE_FIELD(type_instance, 1); + HANDLE_FIELD(host, false); + HANDLE_FIELD(plugin, false); + HANDLE_FIELD(plugin_instance, true); + /* HANDLE_FIELD (type, false); */ + HANDLE_FIELD(type_instance, true); return FC_TARGET_CONTINUE; } /* }}} int tr_invoke */ diff --git a/src/target_v5upgrade.c b/src/target_v5upgrade.c index 12c05d61..650f9a5e 100644 --- a/src/target_v5upgrade.c +++ b/src/target_v5upgrade.c @@ -219,9 +219,9 @@ static int v5_zfs_arc_counts(const data_set_t *ds, value_list_t *vl) /* {{{ */ return FC_TARGET_STOP; if (strcmp("hits", vl->type_instance) == 0) - is_hits = 1; + is_hits = true; else if (strcmp("misses", vl->type_instance) == 0) - is_hits = 0; + is_hits = false; else return FC_TARGET_STOP; diff --git a/src/thermal.c b/src/thermal.c index cbd168b4..959fec64 100644 --- a/src/thermal.c +++ b/src/thermal.c @@ -59,7 +59,7 @@ static int thermal_sysfs_device_read(const char __attribute__((unused)) * dir, const char *name, void __attribute__((unused)) * user_data) { char filename[PATH_MAX]; - bool success = 0; + bool success = false; value_t value; if (device_list && ignorelist_match(device_list, name)) @@ -69,13 +69,13 @@ static int thermal_sysfs_device_read(const char __attribute__((unused)) * dir, if (parse_value_file(filename, &value, DS_TYPE_GAUGE) == 0) { value.gauge /= 1000.0; thermal_submit(name, TEMP, value); - success = 1; + success = true; } snprintf(filename, sizeof(filename), "%s/%s/cur_state", dirname_sysfs, name); if (parse_value_file(filename, &value, DS_TYPE_GAUGE) == 0) { thermal_submit(name, COOLING_DEV, value); - success = 1; + success = true; } return success ? 0 : -1; @@ -157,9 +157,9 @@ static int thermal_config(const char *key, const char *value) { if (IS_TRUE(value)) ignorelist_set_invert(device_list, 0); } else if (strcasecmp(key, "ForceUseProcfs") == 0) { - force_procfs = 0; + force_procfs = false; if (IS_TRUE(value)) - force_procfs = 1; + force_procfs = true; } else { return -1; } diff --git a/src/turbostat.c b/src/turbostat.c index 9a8d7a17..2bc7e3f1 100644 --- a/src/turbostat.c +++ b/src/turbostat.c @@ -243,7 +243,7 @@ static const int config_keys_num = STATIC_ARRAY_SIZE(config_keys); /* * Open a MSR device for reading * Can change the scheduling affinity of the current process if multiple_read is - * 1 + * true */ static int __attribute__((warn_unused_result)) open_msr(unsigned int cpu, bool multiple_read) { @@ -487,7 +487,7 @@ delta_thread(struct thread_data *delta, const struct thread_data *new, "the entire interval. Fix this by running " "Linux-2.6.30 or later."); - aperf_mperf_unstable = 1; + aperf_mperf_unstable = true; } } @@ -895,14 +895,14 @@ static int __attribute__((warn_unused_result)) probe_cpu(void) { switch (model) { /* Atom (partial) */ case 0x27: - do_smi = 0; + do_smi = false; do_core_cstate = 0; do_pkg_cstate = (1 << 2) | (1 << 4) | (1 << 6); break; /* Silvermont */ case 0x37: /* BYT */ case 0x4D: /* AVN */ - do_smi = 1; + do_smi = true; do_core_cstate = (1 << 1) | (1 << 6); do_pkg_cstate = (1 << 6); break; @@ -912,7 +912,7 @@ static int __attribute__((warn_unused_result)) probe_cpu(void) { Forest */ case 0x1F: /* Core i7 and i5 Processor - Nehalem */ case 0x2E: /* Nehalem-EX Xeon - Beckton */ - do_smi = 1; + do_smi = true; do_core_cstate = (1 << 3) | (1 << 6); do_pkg_cstate = (1 << 3) | (1 << 6) | (1 << 7); break; @@ -920,21 +920,21 @@ static int __attribute__((warn_unused_result)) probe_cpu(void) { case 0x25: /* Westmere Client - Clarkdale, Arrandale */ case 0x2C: /* Westmere EP - Gulftown */ case 0x2F: /* Westmere-EX Xeon - Eagleton */ - do_smi = 1; + do_smi = true; do_core_cstate = (1 << 3) | (1 << 6); do_pkg_cstate = (1 << 3) | (1 << 6) | (1 << 7); break; /* Sandy Bridge */ case 0x2A: /* SNB */ case 0x2D: /* SNB Xeon */ - do_smi = 1; + do_smi = true; do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7); do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7); break; /* Ivy Bridge */ case 0x3A: /* IVB */ case 0x3E: /* IVB Xeon */ - do_smi = 1; + do_smi = true; do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7); do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7); break; @@ -942,31 +942,31 @@ static int __attribute__((warn_unused_result)) probe_cpu(void) { case 0x3C: /* HSW */ case 0x3F: /* HSW */ case 0x46: /* HSW */ - do_smi = 1; + do_smi = true; do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7); do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7); break; case 0x45: /* HSW */ - do_smi = 1; + do_smi = true; do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7); do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10); break; - /* Broadwel */ + /* Broadwell */ case 0x4F: /* BDW */ case 0x56: /* BDX-DE */ - do_smi = 1; + do_smi = true; do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7); do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7); break; case 0x3D: /* BDW */ - do_smi = 1; + do_smi = true; do_core_cstate = (1 << 3) | (1 << 6) | (1 << 7); do_pkg_cstate = (1 << 2) | (1 << 3) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10); break; default: - do_smi = 0; + do_smi = false; do_core_cstate = 0; do_pkg_cstate = 0; break; @@ -1227,7 +1227,7 @@ static int __attribute__((warn_unused_result)) topology_probe(void) { if (ret < 0) goto err; else if ((unsigned int)ret == i) - cpu->first_core_in_package = 1; + cpu->first_core_in_package = true; ret = get_threads_on_core(i); if (ret < 0) @@ -1241,7 +1241,7 @@ static int __attribute__((warn_unused_result)) topology_probe(void) { if (ret < 0) goto err; else if ((unsigned int)ret == i) - cpu->first_thread_in_core = 1; + cpu->first_thread_in_core = true; DEBUG("turbostat plugin: cpu %d pkg %d core %d\n", i, cpu->package_id, cpu->core_id); @@ -1338,8 +1338,8 @@ static void initialize_counters(void) { } static void free_all_buffers(void) { - allocated = 0; - initialized = 0; + allocated = false; + initialized = false; CPU_FREE(cpu_present_set); cpu_present_set = NULL; @@ -1400,7 +1400,7 @@ static int setup_all_buffers(void) { DO_OR_GOTO_ERR(for_all_cpus(set_temperature_target, EVEN_COUNTERS)); DO_OR_GOTO_ERR(for_all_cpus(set_temperature_target, ODD_COUNTERS)); - allocated = 1; + allocated = true; return 0; err: free_all_buffers(); @@ -1437,8 +1437,8 @@ static int turbostat_read(void) { if ((ret = for_all_cpus(get_counters, EVEN_COUNTERS)) < 0) goto out; time_even = cdtime(); - is_even = 1; - initialized = 1; + is_even = true; + initialized = true; ret = 0; goto out; } @@ -1447,7 +1447,7 @@ static int turbostat_read(void) { if ((ret = for_all_cpus(get_counters, ODD_COUNTERS)) < 0) goto out; time_odd = cdtime(); - is_even = 0; + is_even = false; time_delta = time_odd - time_even; if ((ret = for_all_cpus_delta(ODD_COUNTERS, EVEN_COUNTERS)) < 0) goto out; @@ -1457,7 +1457,7 @@ static int turbostat_read(void) { if ((ret = for_all_cpus(get_counters, EVEN_COUNTERS)) < 0) goto out; time_even = cdtime(); - is_even = 1; + is_even = true; time_delta = time_even - time_odd; if ((ret = for_all_cpus_delta(EVEN_COUNTERS, ODD_COUNTERS)) < 0) goto out; @@ -1554,7 +1554,7 @@ static int turbostat_config(const char *key, const char *value) { return -1; } config_core_cstate = (unsigned int)tmp_val; - apply_config_core_cstate = 1; + apply_config_core_cstate = true; } else if (strcasecmp("PackageCstates", key) == 0) { tmp_val = strtoul(value, &end, 0); if (*end != '\0' || tmp_val > UINT_MAX) { @@ -1562,16 +1562,16 @@ static int turbostat_config(const char *key, const char *value) { return -1; } config_pkg_cstate = (unsigned int)tmp_val; - apply_config_pkg_cstate = 1; + apply_config_pkg_cstate = true; } else if (strcasecmp("SystemManagementInterrupt", key) == 0) { config_smi = IS_TRUE(value); - apply_config_smi = 1; + apply_config_smi = true; } else if (strcasecmp("DigitalTemperatureSensor", key) == 0) { config_dts = IS_TRUE(value); - apply_config_dts = 1; + apply_config_dts = true; } else if (strcasecmp("PackageThermalManagement", key) == 0) { config_ptm = IS_TRUE(value); - apply_config_ptm = 1; + apply_config_ptm = true; } else if (strcasecmp("LogicalCoreNames", key) == 0) { config_lcn = IS_TRUE(value); } else if (strcasecmp("RunningAveragePowerLimit", key) == 0) { @@ -1581,7 +1581,7 @@ static int turbostat_config(const char *key, const char *value) { return -1; } config_rapl = (unsigned int)tmp_val; - apply_config_rapl = 1; + apply_config_rapl = true; } else if (strcasecmp("TCCActivationTemp", key) == 0) { tmp_val = strtoul(value, &end, 0); if (*end != '\0' || tmp_val > UINT_MAX) { diff --git a/src/unixsock.c b/src/unixsock.c index 67edab17..be80a3a2 100644 --- a/src/unixsock.c +++ b/src/unixsock.c @@ -350,9 +350,9 @@ static int us_config(const char *key, const char *val) { sock_perms = (int)strtol(val, NULL, 8); } else if (strcasecmp(key, "DeleteSocket") == 0) { if (IS_TRUE(val)) - delete_socket = 1; + delete_socket = true; else - delete_socket = 0; + delete_socket = false; } else { return -1; } diff --git a/src/utils_cmd_putval.c b/src/utils_cmd_putval.c index 6f1bc39e..b5b9065b 100644 --- a/src/utils_cmd_putval.c +++ b/src/utils_cmd_putval.c @@ -271,7 +271,7 @@ int cmd_create_putval(char *ret, size_t ret_len, /* {{{ */ escape_string(buffer_ident, sizeof(buffer_ident)); status = format_values(buffer_values, sizeof(buffer_values), ds, vl, - /* store rates = */ 0); + /* store rates = */ false); if (status != 0) return status; escape_string(buffer_values, sizeof(buffer_values)); diff --git a/src/utils_format_graphite.c b/src/utils_format_graphite.c index 6fd02264..0bc802b6 100644 --- a/src/utils_format_graphite.c +++ b/src/utils_format_graphite.c @@ -116,7 +116,7 @@ static int gr_format_name(char *ret, int ret_len, value_list_t const *vl, if (postfix == NULL) postfix = ""; - bool preserve_separator = (flags & GRAPHITE_PRESERVE_SEPARATOR) ? 1 : 0; + bool preserve_separator = (flags & GRAPHITE_PRESERVE_SEPARATOR); gr_copy_escape_part(n_host, vl->host, sizeof(n_host), escape_char, preserve_separator); diff --git a/src/utils_format_json.c b/src/utils_format_json.c index 42cb4451..eae0b18f 100644 --- a/src/utils_format_json.c +++ b/src/utils_format_json.c @@ -267,7 +267,7 @@ static int meta_data_keys_to_json(char *buffer, size_t buffer_size, /* {{{ */ if (meta_data_get_double(meta, key, &value) == 0) BUFFER_ADD(",\"%s\":%f", key, value); } else if (type == MD_TYPE_BOOLEAN) { - bool value = 0; + bool value = false; if (meta_data_get_boolean(meta, key, &value) == 0) BUFFER_ADD(",\"%s\":%s", key, value ? "true" : "false"); } diff --git a/src/utils_vl_lookup.c b/src/utils_vl_lookup.c index bcde0868..03e61f80 100644 --- a/src/utils_vl_lookup.c +++ b/src/utils_vl_lookup.c @@ -119,19 +119,19 @@ static bool lu_part_matches(part_match_t const *match, /* {{{ */ if (match->is_regex) { /* Short cut popular catch-all regex. */ if (strcmp(".*", match->str) == 0) - return 1; + return true; int status = regexec(&match->regex, str, /* nmatch = */ 0, /* pmatch = */ NULL, /* flags = */ 0); if (status == 0) - return 1; + return true; else - return 0; + return false; } else if (strcmp(match->str, str) == 0) - return 1; + return true; else - return 0; + return false; } /* }}} bool lu_part_matches */ static int lu_copy_ident_to_match_part(part_match_t *match_part, /* {{{ */ @@ -141,7 +141,7 @@ static int lu_copy_ident_to_match_part(part_match_t *match_part, /* {{{ */ if ((len < 3) || (ident_part[0] != '/') || (ident_part[len - 1] != '/')) { sstrncpy(match_part->str, ident_part, sizeof(match_part->str)); - match_part->is_regex = 0; + match_part->is_regex = false; return 0; } @@ -160,7 +160,7 @@ static int lu_copy_ident_to_match_part(part_match_t *match_part, /* {{{ */ match_part->str, errbuf); return EINVAL; } - match_part->is_regex = 1; + match_part->is_regex = true; return 0; } /* }}} int lu_copy_ident_to_match_part */ @@ -467,7 +467,7 @@ static void lu_destroy_user_class_list(lookup_t *obj, /* {{{ */ do { \ if (user_class_list->entry.match.field.is_regex) { \ regfree(&user_class_list->entry.match.field.regex); \ - user_class_list->entry.match.field.is_regex = 0; \ + user_class_list->entry.match.field.is_regex = false; \ } \ } while (0) @@ -576,7 +576,7 @@ int lookup_add(lookup_t *obj, /* {{{ */ by_type_entry_t *by_type = NULL; user_class_list_t *user_class_obj; - by_type = lu_search_by_type(obj, ident->type, /* allocate = */ 1); + by_type = lu_search_by_type(obj, ident->type, /* allocate = */ true); if (by_type == NULL) return -1; @@ -605,7 +605,7 @@ int lookup_search(lookup_t *obj, /* {{{ */ if ((obj == NULL) || (ds == NULL) || (vl == NULL)) return -EINVAL; - by_type = lu_search_by_type(obj, vl->type, /* allocate = */ 0); + by_type = lu_search_by_type(obj, vl->type, /* allocate = */ false); if (by_type == NULL) return 0; diff --git a/src/utils_vl_lookup_test.c b/src/utils_vl_lookup_test.c index d7226b97..27bfddf0 100644 --- a/src/utils_vl_lookup_test.c +++ b/src/utils_vl_lookup_test.c @@ -75,7 +75,7 @@ static void *lookup_class_callback(data_set_t const *ds, value_list_t const *vl, strncpy(obj->type, vl->type, sizeof(obj->type)); strncpy(obj->type_instance, vl->type_instance, sizeof(obj->type_instance)); - have_new_obj = 1; + have_new_obj = true; return (void *)obj; } @@ -120,7 +120,7 @@ static int checked_lookup_search(lookup_t *obj, char const *host, ds = &ds_test; expect_new_obj = expect_new; - have_new_obj = 0; + have_new_obj = false; status = lookup_search(obj, ds, &vl); return status; diff --git a/src/varnish.c b/src/varnish.c index 0d939935..b515be89 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -1480,45 +1480,45 @@ static int varnish_config_apply_default(user_config_t *conf) /* {{{ */ if (conf == NULL) return EINVAL; - conf->collect_backend = 1; - conf->collect_cache = 1; - conf->collect_connections = 1; + conf->collect_backend = true; + conf->collect_cache = true; + conf->collect_connections = true; #ifdef HAVE_VARNISH_V3 - conf->collect_dirdns = 0; + conf->collect_dirdns = false; #endif - conf->collect_esi = 0; - conf->collect_fetch = 0; - conf->collect_hcb = 0; - conf->collect_objects = 0; + conf->collect_esi = false; + conf->collect_fetch = false; + conf->collect_hcb = false; + conf->collect_objects = false; #if HAVE_VARNISH_V2 - conf->collect_purge = 0; + conf->collect_purge = false; #else - conf->collect_ban = 0; + conf->collect_ban = false; #endif - conf->collect_session = 0; - conf->collect_shm = 1; + conf->collect_session = false; + conf->collect_shm = true; #if HAVE_VARNISH_V2 - conf->collect_sm = 0; + conf->collect_sm = false; #endif #if HAVE_VARNISH_V2 || HAVE_VARNISH_V4 || HAVE_VARNISH_V5 - conf->collect_sma = 0; + conf->collect_sma = false; #endif - conf->collect_sms = 0; - conf->collect_struct = 0; - conf->collect_totals = 0; + conf->collect_sms = false; + conf->collect_struct = false; + conf->collect_totals = false; #if HAVE_VARNISH_V3 || HAVE_VARNISH_V4 || HAVE_VARNISH_V5 - conf->collect_uptime = 0; + conf->collect_uptime = false; #endif - conf->collect_vcl = 0; - conf->collect_workers = 0; + conf->collect_vcl = false; + conf->collect_workers = false; #if HAVE_VARNISH_V4 || HAVE_VARNISH_V5 - conf->collect_vsm = 0; - conf->collect_lck = 0; - conf->collect_mempool = 0; - conf->collect_mgt = 0; - conf->collect_smf = 0; - conf->collect_vbe = 0; - conf->collect_mse = 0; + conf->collect_vsm = false; + conf->collect_lck = false; + conf->collect_mempool = false; + conf->collect_mgt = false; + conf->collect_smf = false; + conf->collect_vbe = false; + conf->collect_mse = false; #endif return 0; @@ -1771,7 +1771,7 @@ static int varnish_config_instance(const oconfig_item_t *ci) /* {{{ */ .data = conf, .free_func = varnish_config_free, }); - have_instance = 1; + have_instance = true; return 0; } /* }}} int varnish_config_instance */ diff --git a/src/virt.c b/src/virt.c index 6f3e5c80..69a35a7f 100644 --- a/src/virt.c +++ b/src/virt.c @@ -401,7 +401,7 @@ static const struct ex_stats_item ex_stats_table[] = { }; /* BlockDeviceFormatBasename */ -bool blockdevice_format_basename = 0; +static bool blockdevice_format_basename; static enum bd_field blockdevice_format = target; static enum if_field interface_format = if_name; @@ -1177,7 +1177,7 @@ static void vcpu_pin_submit(virDomainPtr dom, int max_cpus, int vcpu, unsigned char *cpu_maps, int cpu_map_len) { for (int cpu = 0; cpu < max_cpus; ++cpu) { char type_instance[DATA_MAX_NAME_LEN]; - bool is_set = VIR_CPU_USABLE(cpu_maps, cpu_map_len, vcpu, cpu) ? 1 : 0; + bool is_set = VIR_CPU_USABLE(cpu_maps, cpu_map_len, vcpu, cpu); snprintf(type_instance, sizeof(type_instance), "vcpu_%d-cpu_%d", vcpu, cpu); submit(dom, "cpu_affinity", type_instance, &(value_t){.gauge = is_set}, 1); diff --git a/src/write_graphite.c b/src/write_graphite.c index 74179121..099c62bb 100644 --- a/src/write_graphite.c +++ b/src/write_graphite.c @@ -65,7 +65,7 @@ #endif #ifndef WG_DEFAULT_LOG_SEND_ERRORS -#define WG_DEFAULT_LOG_SEND_ERRORS 1 +#define WG_DEFAULT_LOG_SEND_ERRORS true #endif #ifndef WG_DEFAULT_ESCAPE @@ -131,7 +131,7 @@ static void wg_force_reconnect_check(struct wg_callback *cb) { close(cb->sock_fd); cb->sock_fd = -1; cb->last_reconnect_time = now; - cb->reconnect_interval_reached = 1; + cb->reconnect_interval_reached = true; INFO("write_graphite plugin: Connection closed after %.3f seconds.", CDTIME_T_TO_DOUBLE(now - cb->last_reconnect_time)); @@ -274,7 +274,7 @@ static int wg_callback_init(struct wg_callback *cb) { if (!cb->reconnect_interval_reached || (cb->send_buf_free == 0)) wg_reset_buffer(cb); else - cb->reconnect_interval_reached = 0; + cb->reconnect_interval_reached = false; return 0; } @@ -466,7 +466,7 @@ static int wg_config_node(oconfig_item_t *ci) { cb->protocol = strdup(WG_DEFAULT_PROTOCOL); cb->last_reconnect_time = cdtime(); cb->reconnect_interval = 0; - cb->reconnect_interval_reached = 0; + cb->reconnect_interval_reached = false; cb->log_send_errors = WG_DEFAULT_LOG_SEND_ERRORS; cb->prefix = NULL; cb->postfix = NULL; diff --git a/src/write_http.c b/src/write_http.c index 8cca82d4..ad0cb5e4 100644 --- a/src/write_http.c +++ b/src/write_http.c @@ -624,16 +624,16 @@ static int wh_config_node(oconfig_item_t *ci) /* {{{ */ ERROR("write_http plugin: calloc failed."); return -1; } - cb->verify_peer = 1; - cb->verify_host = 1; + cb->verify_peer = true; + cb->verify_host = true; cb->format = WH_FORMAT_COMMAND; cb->sslversion = CURL_SSLVERSION_DEFAULT; cb->low_speed_limit = 0; cb->timeout = 0; - cb->log_http_error = 0; + cb->log_http_error = false; cb->headers = NULL; - cb->send_metrics = 1; - cb->send_notifications = 0; + cb->send_metrics = true; + cb->send_notifications = false; cb->data_ttl = 0; cb->metrics_prefix = strdup(WRITE_HTTP_DEFAULT_PREFIX); diff --git a/src/write_kafka.c b/src/write_kafka.c index a19dd899..c120d15d 100644 --- a/src/write_kafka.c +++ b/src/write_kafka.c @@ -273,7 +273,7 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, } tctx->escape_char = '.'; - tctx->store_rates = 1; + tctx->store_rates = true; tctx->format = KAFKA_FORMAT_JSON; tctx->key = NULL; diff --git a/src/write_log.c b/src/write_log.c index 5180a0e7..52ad6104 100644 --- a/src/write_log.c +++ b/src/write_log.c @@ -96,7 +96,7 @@ static int wl_write(const data_set_t *ds, const value_list_t *vl, static int wl_config(oconfig_item_t *ci) /* {{{ */ { - bool format_seen = 0; + bool format_seen = false; for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; @@ -110,7 +110,7 @@ static int wl_config(oconfig_item_t *ci) /* {{{ */ if (format_seen) { WARNING("write_log plugin: Redefining option `%s'.", child->key); } - format_seen = 1; + format_seen = true; if (strcasecmp("Graphite", str) == 0) wl_format = WL_FORMAT_GRAPHITE; diff --git a/src/write_mongodb.c b/src/write_mongodb.c index f9bd1a0a..9cddc916 100644 --- a/src/write_mongodb.c +++ b/src/write_mongodb.c @@ -170,7 +170,7 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ "authentication string."); mongoc_client_destroy(node->client); node->client = NULL; - node->connected = 0; + node->connected = false; return -1; } @@ -179,7 +179,7 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ ERROR("write_mongodb plugin: Authenticating to [%s]:%d for database " "\"%s\" as user \"%s\" failed.", node->host, node->port, node->db, node->user); - node->connected = 0; + node->connected = false; sfree(uri); return -1; } @@ -190,7 +190,7 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ "authentication string."); mongoc_client_destroy(node->client); node->client = NULL; - node->connected = 0; + node->connected = false; return -1; } @@ -198,7 +198,7 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ if (!node->client) { ERROR("write_mongodb plugin: Connecting to [%s]:%d failed.", node->host, node->port); - node->connected = 0; + node->connected = false; sfree(uri); return -1; } @@ -210,11 +210,11 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ ERROR("write_mongodb plugin: error creating/getting database"); mongoc_client_destroy(node->client); node->client = NULL; - node->connected = 0; + node->connected = false; return -1; } - node->connected = 1; + node->connected = true; return 0; } /* }}} int wm_initialize */ @@ -248,7 +248,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */ mongoc_client_destroy(node->client); node->database = NULL; node->client = NULL; - node->connected = 0; + node->connected = false; pthread_mutex_unlock(&node->lock); bson_destroy(bson_record); return -1; @@ -263,7 +263,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */ mongoc_client_destroy(node->client); node->database = NULL; node->client = NULL; - node->connected = 0; + node->connected = false; pthread_mutex_unlock(&node->lock); bson_destroy(bson_record); mongoc_collection_destroy(collection); @@ -291,7 +291,7 @@ static void wm_config_free(void *ptr) /* {{{ */ mongoc_client_destroy(node->client); node->database = NULL; node->client = NULL; - node->connected = 0; + node->connected = false; sfree(node->host); sfree(node); @@ -312,7 +312,7 @@ static int wm_config_node(oconfig_item_t *ci) /* {{{ */ return ENOMEM; } node->port = MONGOC_DEFAULT_PORT; - node->store_rates = 1; + node->store_rates = true; pthread_mutex_init(&node->lock, /* attr = */ NULL); status = cf_util_get_string_buffer(ci, node->name, sizeof(node->name)); diff --git a/src/write_prometheus.c b/src/write_prometheus.c index e7be797f..3b22922a 100644 --- a/src/write_prometheus.c +++ b/src/write_prometheus.c @@ -884,7 +884,7 @@ static int prom_write(data_set_t const *ds, value_list_t const *vl, for (size_t i = 0; i < ds->ds_num; i++) { Io__Prometheus__Client__MetricFamily *fam = - metric_family_get(ds, vl, i, /* allocate = */ 1); + metric_family_get(ds, vl, i, /* allocate = */ true); if (fam == NULL) continue; @@ -911,7 +911,7 @@ static int prom_missing(value_list_t const *vl, for (size_t i = 0; i < ds->ds_num; i++) { Io__Prometheus__Client__MetricFamily *fam = - metric_family_get(ds, vl, i, /* allocate = */ 0); + metric_family_get(ds, vl, i, /* allocate = */ false); if (fam == NULL) continue; diff --git a/src/write_redis.c b/src/write_redis.c index b2c7598e..97c6cc05 100644 --- a/src/write_redis.c +++ b/src/write_redis.c @@ -191,7 +191,7 @@ static int wr_config_node(oconfig_item_t *ci) /* {{{ */ node->database = 0; node->max_set_size = -1; node->max_set_duration = -1; - node->store_rates = 1; + node->store_rates = true; pthread_mutex_init(&node->lock, /* attr = */ NULL); status = cf_util_get_string_buffer(ci, node->name, sizeof(node->name)); diff --git a/src/write_riemann.c b/src/write_riemann.c index 6515fd4d..45f92193 100644 --- a/src/write_riemann.c +++ b/src/write_riemann.c @@ -632,11 +632,11 @@ static int wrr_config_node(oconfig_item_t *ci) /* {{{ */ host->reference_count = 1; host->node = NULL; host->port = 0; - host->notifications = 1; - host->check_thresholds = 0; - host->store_rates = 1; - host->always_append_ds = 0; - host->batch_mode = 1; + host->notifications = true; + host->check_thresholds = false; + host->store_rates = true; + host->always_append_ds = false; + host->batch_mode = true; host->batch_max = RIEMANN_BATCH_MAX; /* typical MSS */ host->batch_init = cdtime(); host->batch_timeout = 0; diff --git a/src/write_sensu.c b/src/write_sensu.c index 04f5aa78..99885a62 100644 --- a/src/write_sensu.c +++ b/src/write_sensu.c @@ -1019,10 +1019,10 @@ static int sensu_config_node(oconfig_item_t *ci) /* {{{ */ host->reference_count = 1; host->node = NULL; host->service = NULL; - host->notifications = 0; - host->metrics = 0; - host->store_rates = 1; - host->always_append_ds = 0; + host->notifications = false; + host->metrics = false; + host->store_rates = true; + host->always_append_ds = false; host->metric_handlers.nb_strs = 0; host->metric_handlers.strs = NULL; host->notification_handlers.nb_strs = 0; @@ -1124,16 +1124,17 @@ static int sensu_config_node(oconfig_item_t *ci) /* {{{ */ return -1; } - if ((host->notification_handlers.nb_strs > 0) && (host->notifications == 0)) { + if ((host->notification_handlers.nb_strs > 0) && + (host->notifications == false)) { WARNING("write_sensu plugin: NotificationHandler given so forcing " "notifications to be enabled"); host->notifications = 1; } - if ((host->metric_handlers.nb_strs > 0) && (host->metrics == 0)) { + if ((host->metric_handlers.nb_strs > 0) && (host->metrics == false)) { WARNING("write_sensu plugin: MetricHandler given so forcing metrics to be " "enabled"); - host->metrics = 1; + host->metrics = true; } if (!(host->notifications || host->metrics)) { -- 2.11.0