From ec51ddee94fa2ba1e01fe0e336ccc9c190a198ff Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Mon, 14 May 2018 14:10:34 +0200 Subject: [PATCH] Don't initialize static numeric variables to 0 --- src/amqp.c | 4 ++-- src/apcups.c | 4 ++-- src/ascent.c | 4 ++-- src/barometer.c | 8 ++++---- src/bind.c | 8 ++++---- src/ceph.c | 4 ++-- src/collectd-nagios.c | 2 +- src/collectdmon.c | 10 +++++----- src/conntrack.c | 2 +- src/cpu.c | 4 ++-- src/cpufreq.c | 2 +- src/csv.c | 4 ++-- src/daemon/collectd.c | 2 +- src/daemon/filter_chain.c | 2 +- src/daemon/plugin.c | 14 +++++++------- src/daemon/utils_avltree_test.c | 5 +++-- src/dbi.c | 8 ++++---- src/disk.c | 2 +- src/dns.c | 2 +- src/email.c | 2 +- src/ethstat.c | 2 +- src/filecount.c | 2 +- src/gmond.c | 10 +++++----- src/interface.c | 2 +- src/iptables.c | 2 +- src/java.c | 4 ++-- src/libcollectdclient/network_buffer.c | 4 ++-- src/libcollectdclient/network_parse.c | 2 +- src/logfile.c | 2 +- src/madwifi.c | 2 +- src/mic.c | 2 +- src/mqtt.c | 2 +- src/netlink.c | 2 +- src/network.c | 32 ++++++++++++++++---------------- src/nfs.c | 4 ++-- src/nginx.c | 2 +- src/notify_email.c | 2 +- src/nut.c | 4 ++-- src/onewire.c | 2 +- src/oracle.c | 4 ++-- src/perl.c | 2 +- src/pinba.c | 2 +- src/ping.c | 4 ++-- src/postgresql.c | 8 ++++---- src/python.c | 4 ++-- src/rrdtool.c | 12 ++++++------ src/sensors.c | 2 +- src/smart.c | 4 ++-- src/snmp.c | 2 +- src/syslog.c | 2 +- src/tail.c | 2 +- src/tape.c | 2 +- src/tcpconns.c | 8 ++++---- src/ted.c | 2 +- src/testing.h | 4 ++-- src/unixsock.c | 4 ++-- src/utils_dns.c | 6 +++--- src/utils_ovs.c | 2 +- src/virt.c | 2 +- src/vmem.c | 2 +- src/vserver.c | 2 +- src/write_tsdb.c | 4 ++-- 62 files changed, 132 insertions(+), 131 deletions(-) diff --git a/src/amqp.c b/src/amqp.c index 7a91ba11..281130b1 100644 --- a/src/amqp.c +++ b/src/amqp.c @@ -112,7 +112,7 @@ static const char *def_password = "guest"; static const char *def_exchange = "amq.fanout"; static pthread_t *subscriber_threads; -static size_t subscriber_threads_num = 0; +static size_t subscriber_threads_num; static bool subscriber_threads_running = true; #define CONF(c, f) (((c)->f != NULL) ? (c)->f : def_##f) @@ -396,7 +396,7 @@ static int camqp_setup_queue(camqp_config_t *conf) /* {{{ */ static int camqp_connect(camqp_config_t *conf) /* {{{ */ { - static time_t last_connect_time = 0; + static time_t last_connect_time; amqp_rpc_reply_t reply; int status; diff --git a/src/apcups.c b/src/apcups.c index 4e84ebd2..2931d2c0 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -78,8 +78,8 @@ static bool conf_persistent_conn = true; static int global_sockfd = -1; -static int count_retries = 0; -static int count_iterations = 0; +static int count_retries; +static int count_iterations; static int net_shutdown(int *fd) { uint16_t packet_size = 0; diff --git a/src/ascent.c b/src/ascent.c index 09dd5de7..22358658 100644 --- a/src/ascent.c +++ b/src/ascent.c @@ -98,8 +98,8 @@ static char *timeout; static CURL *curl; static char *ascent_buffer; -static size_t ascent_buffer_size = 0; -static size_t ascent_buffer_fill = 0; +static size_t ascent_buffer_size; +static size_t ascent_buffer_fill; static char ascent_curl_error[CURL_ERROR_SIZE]; static const char *config_keys[] = { diff --git a/src/barometer.c b/src/barometer.c index 17c2a1a2..66ab20c0 100644 --- a/src/barometer.c +++ b/src/barometer.c @@ -180,11 +180,11 @@ static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); static char *config_device; /**< I2C bus device */ static int config_oversample = 1; /**< averaging window */ -static double config_press_offset = 0.0; /**< pressure offset */ -static double config_temp_offset = 0.0; /**< temperature offset */ +static double config_press_offset; /**< pressure offset */ +static double config_temp_offset; /**< temperature offset */ static double config_altitude = NAN; /**< altitude */ -static int config_normalize = 0; /**< normalization method */ +static int config_normalize; /**< normalization method */ static bool configured; /**< the whole plugin config status */ @@ -193,7 +193,7 @@ static int i2c_bus_fd = -1; /**< I2C bus device FD */ static enum Sensor_type sensor_type = Sensor_none; /**< detected/used sensor type */ -static __s32 mpl3115_oversample = 0; /**< MPL3115 CTRL1 oversample setting */ +static __s32 mpl3115_oversample; /**< MPL3115 CTRL1 oversample setting */ // BMP085 configuration static unsigned bmp085_oversampling; /**< BMP085 oversampling (0-3) */ diff --git a/src/bind.c b/src/bind.c index 2d10aba8..370ebc58 100644 --- a/src/bind.c +++ b/src/bind.c @@ -111,18 +111,18 @@ static int global_opcodes = 1; static int global_qtypes = 1; static int global_server_stats = 1; static int global_zone_maint_stats = 1; -static int global_resolver_stats = 0; +static int global_resolver_stats; static int global_memory_stats = 1; static int timeout = -1; static cb_view_t *views; -static size_t views_num = 0; +static size_t views_num; static CURL *curl; static char *bind_buffer; -static size_t bind_buffer_size = 0; -static size_t bind_buffer_fill = 0; +static size_t bind_buffer_size; +static size_t bind_buffer_fill; static char bind_curl_error[CURL_ERROR_SIZE]; /* Translation table for the `nsstats' values. */ diff --git a/src/ceph.c b/src/ceph.c index e2c98ed0..2622dc73 100644 --- a/src/ceph.c +++ b/src/ceph.c @@ -148,7 +148,7 @@ enum perfcounter_type_d { }; /** Give user option to use default (long run = since daemon started) avg */ -static int long_run_latency_avg = 0; +static int long_run_latency_avg; /** * Give user option to use default type for special cases - @@ -164,7 +164,7 @@ static int convert_special_metrics = 1; static struct ceph_daemon **g_daemons; /** Number of elements in g_daemons */ -static size_t g_num_daemons = 0; +static size_t g_num_daemons; /** * A set of data that we build up in memory while parsing the JSON. diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index 68ed437c..54be36aa 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -104,7 +104,7 @@ static int consolitation_g = CON_NONE; static bool nan_is_error_g; static char **match_ds_g; -static size_t match_ds_num_g = 0; +static size_t match_ds_num_g; /* `strdup' is an XSI extension. I don't want to pull in all of XSI just for * that, so here's an own implementation.. It's easy enough. The GCC attributes diff --git a/src/collectdmon.c b/src/collectdmon.c index 6c198895..089e52b6 100644 --- a/src/collectdmon.c +++ b/src/collectdmon.c @@ -71,11 +71,11 @@ #define WCOREDUMP(s) 0 #endif /* ! WCOREDUMP */ -static int loop = 0; -static int restart = 0; +static int loop; +static int restart; static const char *pidfile; -static pid_t collectd_pid = 0; +static pid_t collectd_pid; __attribute__((noreturn)) static void exit_usage(const char *name) { printf("Usage: %s [-- ]\n" @@ -246,8 +246,8 @@ static void log_status(int status) { static void check_respawn(void) { time_t t = time(NULL); - static time_t timestamp = 0; - static int counter = 0; + static time_t timestamp; + static int counter; if ((t - 120) < timestamp) ++counter; diff --git a/src/conntrack.c b/src/conntrack.c index 3cd2deee..29c7003e 100644 --- a/src/conntrack.c +++ b/src/conntrack.c @@ -41,7 +41,7 @@ static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); Each table/chain combo that will be queried goes into this list */ -static int old_files = 0; +static int old_files; static int conntrack_config(const char *key, const char *value) { if (strcmp(key, "OldFiles") == 0) diff --git a/src/cpu.c b/src/cpu.c index 7478a4ab..2a697129 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -188,11 +188,11 @@ struct cpu_state_s { typedef struct cpu_state_s cpu_state_t; static cpu_state_t *cpu_states; -static size_t cpu_states_num = 0; /* #cpu_states allocated */ +static size_t cpu_states_num; /* #cpu_states allocated */ /* Highest CPU number in the current iteration. Used by the dispatch logic to * determine how many CPUs there were. Reset to 0 by cpu_reset(). */ -static size_t global_cpu_num = 0; +static size_t global_cpu_num; static bool report_by_cpu = true; static bool report_by_state = true; diff --git a/src/cpufreq.c b/src/cpufreq.c index 0139947e..851aad42 100644 --- a/src/cpufreq.c +++ b/src/cpufreq.c @@ -25,7 +25,7 @@ #include "common.h" #include "plugin.h" -static int num_cpu = 0; +static int num_cpu; static int cpufreq_init(void) { int status; diff --git a/src/csv.c b/src/csv.c index 34fc2238..be59ede0 100644 --- a/src/csv.c +++ b/src/csv.c @@ -34,8 +34,8 @@ static const char *config_keys[] = {"DataDir", "StoreRates"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); static char *datadir; -static int store_rates = 0; -static int use_stdio = 0; +static int store_rates; +static int use_stdio; static int value_list_to_string(char *buffer, int buffer_len, const data_set_t *ds, const value_list_t *vl) { diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c index 3b959c76..d15bb334 100644 --- a/src/daemon/collectd.c +++ b/src/daemon/collectd.c @@ -51,7 +51,7 @@ #define COLLECTD_LOCALE "C" #endif -static int loop = 0; +static int loop; static void *do_flush(void __attribute__((unused)) * arg) { INFO("Flushing all data."); diff --git a/src/daemon/filter_chain.c b/src/daemon/filter_chain.c index 1352f5b3..a0a76876 100644 --- a/src/daemon/filter_chain.c +++ b/src/daemon/filter_chain.c @@ -693,7 +693,7 @@ static int fc_bit_write_invoke(const data_set_t *ds, /* {{{ */ static int fc_init_once(void) /* {{{ */ { - static int done = 0; + static int done; target_proc_t tproc = {0}; if (done != 0) diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c index 5374d8d2..427a8134 100644 --- a/src/daemon/plugin.c +++ b/src/daemon/plugin.c @@ -120,25 +120,25 @@ static int read_loop = 1; static pthread_mutex_t read_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t read_cond = PTHREAD_COND_INITIALIZER; static pthread_t *read_threads; -static size_t read_threads_num = 0; +static size_t read_threads_num; static cdtime_t max_read_interval = DEFAULT_MAX_READ_INTERVAL; static write_queue_t *write_queue_head; static write_queue_t *write_queue_tail; -static long write_queue_length = 0; +static long write_queue_length; static bool write_loop = true; static pthread_mutex_t write_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t write_cond = PTHREAD_COND_INITIALIZER; static pthread_t *write_threads; -static size_t write_threads_num = 0; +static size_t write_threads_num; static pthread_key_t plugin_ctx_key; static bool plugin_ctx_key_initialized; -static long write_limit_high = 0; -static long write_limit_low = 0; +static long write_limit_high; +static long write_limit_low; -static derive_t stats_values_dropped = 0; +static derive_t stats_values_dropped; static bool record_statistics; /* @@ -2025,7 +2025,7 @@ static double get_drop_probability(void) /* {{{ */ static bool check_drop_value(void) /* {{{ */ { - static cdtime_t last_message_time = 0; + static cdtime_t last_message_time; static pthread_mutex_t last_message_lock = PTHREAD_MUTEX_INITIALIZER; double p; diff --git a/src/daemon/utils_avltree_test.c b/src/daemon/utils_avltree_test.c index bb30f9d6..3171246a 100644 --- a/src/daemon/utils_avltree_test.c +++ b/src/daemon/utils_avltree_test.c @@ -24,13 +24,14 @@ * Florian octo Forster */ -#include "common.h" /* STATIC_ARRAY_SIZE */ #include "collectd.h" +#include "common.h" /* STATIC_ARRAY_SIZE */ #include "testing.h" #include "utils_avltree.h" -static int compare_total_count = 0; +static int compare_total_count; + #define RESET_COUNTS() \ do { \ compare_total_count = 0; \ diff --git a/src/dbi.c b/src/dbi.c index dcc32e68..4ef9f8c5 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -83,12 +83,12 @@ typedef struct cdbi_database_s cdbi_database_t; /* }}} */ * Global variables */ #if !defined(HAVE_LEGACY_LIBDBI) || !HAVE_LEGACY_LIBDBI -static dbi_inst dbi_instance = 0; +static dbi_inst dbi_instance; #endif static udb_query_t **queries; -static size_t queries_num = 0; +static size_t queries_num; static cdbi_database_t **databases; -static size_t databases_num = 0; +static size_t databases_num; static int cdbi_read_database(user_data_t *ud); @@ -407,7 +407,7 @@ static int cdbi_config(oconfig_item_t *ci) /* {{{ */ static int cdbi_init(void) /* {{{ */ { - static int did_init = 0; + static int did_init; int status; if (did_init != 0) diff --git a/src/disk.c b/src/disk.c index 7b5c0249..206862ba 100644 --- a/src/disk.c +++ b/src/disk.c @@ -126,7 +126,7 @@ static struct gmesh geom_tree; #define MAX_NUMDISK 1024 extern kstat_ctl_t *kc; static kstat_t *ksp[MAX_NUMDISK]; -static int numdisk = 0; +static int numdisk; /* #endif HAVE_LIBKSTAT */ #elif defined(HAVE_LIBSTATGRAB) diff --git a/src/dns.c b/src/dns.c index ef627eb8..bd6820fa 100644 --- a/src/dns.c +++ b/src/dns.c @@ -66,7 +66,7 @@ static counter_list_t *opcode_list; static counter_list_t *rcode_list; static pthread_t listen_thread; -static int listen_thread_init = 0; +static int listen_thread_init; /* The `traffic' mutex if for `tr_queries' and `tr_responses' */ static pthread_mutex_t traffic_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t qtype_mutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/src/email.c b/src/email.c index 4f49cfb3..376dd6a5 100644 --- a/src/email.c +++ b/src/email.c @@ -117,7 +117,7 @@ static int sock_perms = S_IRWXU | S_IRWXG; static int max_conns = MAX_CONNS; /* state of the plugin */ -static int disabled = 0; +static int disabled; /* thread managing "client" connections */ static pthread_t connector = (pthread_t)0; diff --git a/src/ethstat.c b/src/ethstat.c index 371020c9..0d4c7e15 100644 --- a/src/ethstat.c +++ b/src/ethstat.c @@ -49,7 +49,7 @@ struct value_map_s { typedef struct value_map_s value_map_t; static char **interfaces; -static size_t interfaces_num = 0; +static size_t interfaces_num; static c_avl_tree_t *value_map; diff --git a/src/filecount.c b/src/filecount.c index 26c7da32..ef1a1387 100644 --- a/src/filecount.c +++ b/src/filecount.c @@ -61,7 +61,7 @@ struct fc_directory_conf_s { typedef struct fc_directory_conf_s fc_directory_conf_t; static fc_directory_conf_t **directories; -static size_t directories_num = 0; +static size_t directories_num; static void fc_free_dir(fc_directory_conf_t *dir) { sfree(dir->path); diff --git a/src/gmond.c b/src/gmond.c index 6ed4115d..ca654194 100644 --- a/src/gmond.c +++ b/src/gmond.c @@ -89,14 +89,14 @@ static char *mc_receive_group; static char *mc_receive_port; static struct pollfd *mc_receive_sockets; -static size_t mc_receive_sockets_num = 0; +static size_t mc_receive_sockets_num; static socket_entry_t *mc_send_sockets; -static size_t mc_send_sockets_num = 0; +static size_t mc_send_sockets_num; static pthread_mutex_t mc_send_sockets_lock = PTHREAD_MUTEX_INITIALIZER; -static int mc_receive_thread_loop = 0; -static int mc_receive_thread_running = 0; +static int mc_receive_thread_loop; +static int mc_receive_thread_running; static pthread_t mc_receive_thread_id; static metric_map_t metric_map_default[] = @@ -123,7 +123,7 @@ static metric_map_t metric_map_default[] = static size_t metric_map_len_default = STATIC_ARRAY_SIZE(metric_map_default); static metric_map_t *metric_map; -static size_t metric_map_len = 0; +static size_t metric_map_len; static c_avl_tree_t *staging_tree; static pthread_mutex_t staging_lock = PTHREAD_MUTEX_INITIALIZER; diff --git a/src/interface.c b/src/interface.c index 40609658..86110b0c 100644 --- a/src/interface.c +++ b/src/interface.c @@ -97,7 +97,7 @@ static bool report_inactive = true; #define MAX_NUMIF 256 extern kstat_ctl_t *kc; static kstat_t *ksp[MAX_NUMIF]; -static int numif = 0; +static int numif; static bool unique_name; #endif /* HAVE_LIBKSTAT */ diff --git a/src/iptables.c b/src/iptables.c index c1f42d73..8fad588e 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -87,7 +87,7 @@ typedef struct { } ip_chain_t; static ip_chain_t **chain_list; -static int chain_num = 0; +static int chain_num; static int iptables_config(const char *key, const char *value) { /* int ip_value; */ diff --git a/src/java.c b/src/java.c index 56b48df2..449e816f 100644 --- a/src/java.c +++ b/src/java.c @@ -82,7 +82,7 @@ static pthread_key_t jvm_env_key; /* Configuration options for the JVM. */ static char **jvm_argv; -static size_t jvm_argc = 0; +static size_t jvm_argc; /* List of class names to load */ static java_plugin_class_t *java_classes_list; @@ -90,7 +90,7 @@ static size_t java_classes_list_len; /* List of config, init, and shutdown callbacks. */ static cjni_callback_info_t *java_callbacks; -static size_t java_callbacks_num = 0; +static size_t java_callbacks_num; static pthread_mutex_t java_callbacks_lock = PTHREAD_MUTEX_INITIALIZER; static oconfig_item_t *config_block; diff --git a/src/libcollectdclient/network_buffer.c b/src/libcollectdclient/network_buffer.c index 373dd2b7..5a1ee8d0 100644 --- a/src/libcollectdclient/network_buffer.c +++ b/src/libcollectdclient/network_buffer.c @@ -156,7 +156,7 @@ static bool have_gcrypt(void) /* {{{ */ #ifndef HAVE_HTONLL static uint64_t htonll(uint64_t val) /* {{{ */ { - static int config = 0; + static int config; uint32_t hi; uint32_t lo; @@ -186,7 +186,7 @@ static uint64_t htonll(uint64_t val) /* {{{ */ static double htond(double val) /* {{{ */ { - static int config = 0; + static int config; union { uint8_t byte[8]; diff --git a/src/libcollectdclient/network_parse.c b/src/libcollectdclient/network_parse.c index 91fe18de..34ea2194 100644 --- a/src/libcollectdclient/network_parse.c +++ b/src/libcollectdclient/network_parse.c @@ -221,7 +221,7 @@ static int parse_time(uint16_t type, void *payload, size_t payload_size, static double ntohd(double val) /* {{{ */ { - static int config = 0; + static int config; union { uint8_t byte[8]; diff --git a/src/logfile.c b/src/logfile.c index 2b7fbaeb..fa56a1bc 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -41,7 +41,7 @@ static pthread_mutex_t file_lock = PTHREAD_MUTEX_INITIALIZER; static char *log_file; static int print_timestamp = 1; -static int print_severity = 0; +static int print_severity; static const char *config_keys[] = {"LogLevel", "File", "Timestamp", "PrintSeverity"}; diff --git a/src/madwifi.c b/src/madwifi.c index 9d1db55f..60ac3c8c 100644 --- a/src/madwifi.c +++ b/src/madwifi.c @@ -350,7 +350,7 @@ static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); static ignorelist_t *ignorelist; static int use_sysfs = 1; -static int init_state = 0; +static int init_state; static inline int item_watched(int i) { assert(i >= 0); diff --git a/src/mic.c b/src/mic.c index 0c4ace66..4f4a9bac 100644 --- a/src/mic.c +++ b/src/mic.c @@ -35,7 +35,7 @@ #define MAX_CORES 256 static MicDeviceOnSystem mics[MAX_MICS]; -static U32 num_mics = 0; +static U32 num_mics; static HANDLE mic_handle; static int const therm_ids[] = { diff --git a/src/mqtt.c b/src/mqtt.c index 9e56827a..48c34edc 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -89,7 +89,7 @@ struct mqtt_client_conf { typedef struct mqtt_client_conf mqtt_client_conf_t; static mqtt_client_conf_t **subscribers; -static size_t subscribers_num = 0; +static size_t subscribers_num; /* * Functions diff --git a/src/netlink.c b/src/netlink.c index e99e38bc..04585479 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -97,7 +97,7 @@ static ir_ignorelist_t *ir_ignorelist_head; static struct mnl_socket *nl; static char **iflist; -static size_t iflist_len = 0; +static size_t iflist_len; static const char *config_keys[] = {"Interface", "VerboseInterface", "QDisc", "Class", diff --git a/src/network.c b/src/network.c index abed5b87..84ba00b5 100644 --- a/src/network.c +++ b/src/network.c @@ -261,7 +261,7 @@ typedef struct receive_list_entry_s receive_list_entry_t; /* * Private variables */ -static int network_config_ttl = 0; +static int network_config_ttl; /* Ethernet - (IPv6 + UDP) = 1500 - (40 + 8) = 1452 */ static size_t network_config_packet_size = 1452; static bool network_config_forward; @@ -273,18 +273,18 @@ static receive_list_entry_t *receive_list_head; static receive_list_entry_t *receive_list_tail; static pthread_mutex_t receive_list_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t receive_list_cond = PTHREAD_COND_INITIALIZER; -static uint64_t receive_list_length = 0; +static uint64_t receive_list_length; static sockent_t *listen_sockets; static struct pollfd *listen_sockets_pollfd; -static size_t listen_sockets_num = 0; +static size_t listen_sockets_num; /* The receive and dispatch threads will run as long as `listen_loop' is set to * zero. */ -static int listen_loop = 0; -static int receive_thread_running = 0; +static int listen_loop; +static int receive_thread_running; static pthread_t receive_thread_id; -static int dispatch_thread_running = 0; +static int dispatch_thread_running; static pthread_t dispatch_thread_id; /* Buffer in which to-be-sent network packets are constructed. */ @@ -301,14 +301,14 @@ static pthread_mutex_t send_buffer_lock = PTHREAD_MUTEX_INITIALIZER; * example). Only if neither is true, the stats_lock is acquired. The counters * are always read without holding a lock in the hope that writing 8 bytes to * memory is an atomic operation. */ -static derive_t stats_octets_rx = 0; -static derive_t stats_octets_tx = 0; -static derive_t stats_packets_rx = 0; -static derive_t stats_packets_tx = 0; -static derive_t stats_values_dispatched = 0; -static derive_t stats_values_not_dispatched = 0; -static derive_t stats_values_sent = 0; -static derive_t stats_values_not_sent = 0; +static derive_t stats_octets_rx; +static derive_t stats_octets_tx; +static derive_t stats_packets_rx; +static derive_t stats_packets_tx; +static derive_t stats_values_dispatched; +static derive_t stats_values_not_dispatched; +static derive_t stats_values_sent; +static derive_t stats_values_not_sent; static pthread_mutex_t stats_lock = PTHREAD_MUTEX_INITIALIZER; /* @@ -1113,7 +1113,7 @@ static int parse_part_sign_sha256(sockent_t *se, /* {{{ */ static int parse_part_sign_sha256(sockent_t *se, /* {{{ */ void **ret_buffer, size_t *ret_buffer_size, int flags) { - static int warning_has_been_printed = 0; + static int warning_has_been_printed; char *buffer; size_t buffer_size; @@ -1268,7 +1268,7 @@ static int parse_part_encr_aes256(sockent_t *se, /* {{{ */ static int parse_part_encr_aes256(sockent_t *se, /* {{{ */ void **ret_buffer, size_t *ret_buffer_size, int flags) { - static int warning_has_been_printed = 0; + static int warning_has_been_printed; char *buffer; size_t buffer_size; diff --git a/src/nfs.c b/src/nfs.c index e031cb70..e1987f1f 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -409,7 +409,7 @@ static int nfs_submit_fields_safe(int nfs_version, const char *instance, static int nfs_submit_nfs4_server(const char *instance, char **fields, size_t fields_num) { - static int suppress_warning = 0; + static int suppress_warning; size_t proc4x_names_num; switch (fields_num) { @@ -451,7 +451,7 @@ static int nfs_submit_nfs4_client(const char *instance, char **fields, size_t fields_num) { size_t proc40_names_num, proc4x_names_num; - static int suppress_warning = 0; + static int suppress_warning; switch (fields_num) { case 34: diff --git a/src/nginx.c b/src/nginx.c index 23feb1cd..e5ca89c0 100644 --- a/src/nginx.c +++ b/src/nginx.c @@ -44,7 +44,7 @@ static char *timeout; static CURL *curl; static char nginx_buffer[16384]; -static size_t nginx_buffer_len = 0; +static size_t nginx_buffer_len; static char nginx_curl_error[CURL_ERROR_SIZE]; static const char *config_keys[] = { diff --git a/src/notify_email.c b/src/notify_email.c index eb9ec00c..6b32ad9a 100644 --- a/src/notify_email.c +++ b/src/notify_email.c @@ -38,7 +38,7 @@ static const char *config_keys[] = {"SMTPServer", "SMTPPort", "SMTPUser", static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); static char **recipients; -static int recipients_len = 0; +static int recipients_len; static smtp_session_t session; static pthread_mutex_t session_lock = PTHREAD_MUTEX_INITIALIZER; diff --git a/src/nut.c b/src/nut.c index a51c4c0b..1d1e94b5 100644 --- a/src/nut.c +++ b/src/nut.c @@ -53,8 +53,8 @@ struct nut_ups_s { static const char *config_keys[] = {"UPS", "FORCESSL", "VERIFYPEER", "CAPATH", "CONNECTTIMEOUT"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); -static int force_ssl = 0; // Initialized to default of 0 (false) -static int verify_peer = 0; // Initialized to default of 0 (false) +static int force_ssl; // Initialized to default of 0 (false) +static int verify_peer; // Initialized to default of 0 (false) static int ssl_flags = UPSCLI_CONN_TRYSSL; static int connect_timeout = -1; static char *ca_path; diff --git a/src/onewire.c b/src/onewire.c index b1d4cbe1..49c6aa37 100644 --- a/src/onewire.c +++ b/src/onewire.c @@ -87,7 +87,7 @@ static ow_family_features_t ow_family_features[] = { static int ow_family_features_num = STATIC_ARRAY_SIZE(ow_family_features); static char *device_g; -static cdtime_t ow_interval = 0; +static cdtime_t ow_interval; static bool direct_access; static const char *config_keys[] = {"Device", "IgnoreSelected", "Sensor", diff --git a/src/oracle.c b/src/oracle.c index 9c4b929d..c76bce20 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -76,9 +76,9 @@ typedef struct o_database_s o_database_t; * Global variables */ static udb_query_t **queries; -static size_t queries_num = 0; +static size_t queries_num; static o_database_t **databases; -static size_t databases_num = 0; +static size_t databases_num; OCIEnv *oci_env = NULL; OCIError *oci_error = NULL; diff --git a/src/perl.c b/src/perl.c index d760b417..4c6387da 100644 --- a/src/perl.c +++ b/src/perl.c @@ -192,7 +192,7 @@ static c_ithread_list_t *perl_threads; /* the key used to store each pthread's ithread */ static pthread_key_t perl_thr_key; -static int perl_argc = 0; +static int perl_argc; static char **perl_argv; static char base_name[DATA_MAX_NAME_LEN] = ""; diff --git a/src/pinba.c b/src/pinba.c index a323b45b..66b9cd1f 100644 --- a/src/pinba.c +++ b/src/pinba.c @@ -100,7 +100,7 @@ typedef struct pinba_statnode_s pinba_statnode_t; */ /* {{{ */ static pinba_statnode_t *stat_nodes; -static unsigned int stat_nodes_num = 0; +static unsigned int stat_nodes_num; static pthread_mutex_t stat_nodes_lock; static char *conf_node; diff --git a/src/ping.c b/src/ping.c index f89c830c..ffb16910 100644 --- a/src/ping.c +++ b/src/ping.c @@ -84,8 +84,8 @@ static int ping_max_missed = -1; static pthread_mutex_t ping_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t ping_cond = PTHREAD_COND_INITIALIZER; -static int ping_thread_loop = 0; -static int ping_thread_error = 0; +static int ping_thread_loop; +static int ping_thread_error; static pthread_t ping_thread_id; static const char *config_keys[] = {"Host", "SourceAddress", "AddressFamily", diff --git a/src/postgresql.c b/src/postgresql.c index 9adba7d2..7c140e0a 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -156,13 +156,13 @@ static const char *const def_queries[] = { static int def_queries_num = STATIC_ARRAY_SIZE(def_queries); static c_psql_database_t **databases; -static size_t databases_num = 0; +static size_t databases_num; static udb_query_t **queries; -static size_t queries_num = 0; +static size_t queries_num; static c_psql_writer_t *writers; -static size_t writers_num = 0; +static size_t writers_num; static int c_psql_begin(c_psql_database_t *db) { PGresult *r = PQexec(db->conn, "BEGIN"); @@ -1237,7 +1237,7 @@ static int c_psql_config_database(oconfig_item_t *ci) { } /* c_psql_config_database */ static int c_psql_config(oconfig_item_t *ci) { - static int have_def_config = 0; + static int have_def_config; if (0 == have_def_config) { oconfig_item_t *c; diff --git a/src/python.c b/src/python.c index 969a4db8..64db6985 100644 --- a/src/python.c +++ b/src/python.c @@ -257,8 +257,8 @@ static cpy_callback_t *cpy_init_callbacks; static cpy_callback_t *cpy_shutdown_callbacks; /* Make sure to hold the GIL while modifying these. */ -static int cpy_shutdown_triggered = 0; -static int cpy_num_callbacks = 0; +static int cpy_shutdown_triggered; +static int cpy_num_callbacks; static void cpy_destroy_user_data(void *data) { cpy_callback_t *c = data; diff --git a/src/rrdtool.c b/src/rrdtool.c index c93e9fce..5c87a434 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -67,7 +67,7 @@ static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); * is zero a default, depending on the `interval' member of the value list is * being used. */ static char *datadir; -static double write_rate = 0.0; +static double write_rate; static rrdcreate_config_t rrdcreate_config = { /* stepsize = */ 0, /* heartbeat = */ 0, @@ -84,9 +84,9 @@ static rrdcreate_config_t rrdcreate_config = { /* XXX: If you need to lock both, cache_lock and queue_lock, at the same time, * ALWAYS lock `cache_lock' first! */ -static cdtime_t cache_timeout = 0; -static cdtime_t cache_flush_timeout = 0; -static cdtime_t random_timeout = 0; +static cdtime_t cache_timeout; +static cdtime_t cache_flush_timeout; +static cdtime_t random_timeout; static cdtime_t cache_flush_last; static c_avl_tree_t *cache; static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER; @@ -104,7 +104,7 @@ static pthread_cond_t queue_cond = PTHREAD_COND_INITIALIZER; static pthread_mutex_t librrd_lock = PTHREAD_MUTEX_INITIALIZER; #endif -static int do_shutdown = 0; +static int do_shutdown; #if HAVE_THREADSAFE_LIBRRD static int srrd_update(char *filename, char *template, int argc, @@ -1010,7 +1010,7 @@ static int rrd_shutdown(void) { } /* int rrd_shutdown */ static int rrd_init(void) { - static int init_once = 0; + static int init_once; if (init_once != 0) return 0; diff --git a/src/sensors.c b/src/sensors.c index 47db4e33..41cccf1b 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -251,7 +251,7 @@ static void sensors_free_features(void) { } static int sensors_load_conf(void) { - static int call_once = 0; + static int call_once; FILE *fh = NULL; featurelist_t *last_feature = NULL; diff --git a/src/smart.c b/src/smart.c index 9f84955b..62cbb4f1 100644 --- a/src/smart.c +++ b/src/smart.c @@ -43,8 +43,8 @@ static const char *config_keys[] = {"Disk", "IgnoreSelected", "IgnoreSleepMode", static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); static ignorelist_t *ignorelist; -static int ignore_sleep_mode = 0; -static int use_serial = 0; +static int ignore_sleep_mode; +static int use_serial; static int smart_config(const char *key, const char *value) { if (ignorelist == NULL) diff --git a/src/snmp.c b/src/snmp.c index b616f677..433f5f86 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -219,7 +219,7 @@ static void csnmp_host_definition_destroy(void *arg) /* {{{ */ * +-> csnmp_config_add_host_security_level */ static void call_snmp_init_once(void) { - static int have_init = 0; + static int have_init; if (have_init == 0) init_snmp(PACKAGE_NAME); diff --git a/src/syslog.c b/src/syslog.c index 90a97fb5..beb82456 100644 --- a/src/syslog.c +++ b/src/syslog.c @@ -38,7 +38,7 @@ static int log_level = LOG_DEBUG; #else static int log_level = LOG_INFO; #endif /* COLLECT_DEBUG */ -static int notif_severity = 0; +static int notif_severity; static const char *config_keys[] = { "LogLevel", "NotifyLevel", diff --git a/src/tail.c b/src/tail.c index 3d52380a..a6471d83 100644 --- a/src/tail.c +++ b/src/tail.c @@ -60,7 +60,7 @@ struct ctail_config_match_s { typedef struct ctail_config_match_s ctail_config_match_t; static cu_tail_match_t **tail_match_list; -static size_t tail_match_list_num = 0; +static size_t tail_match_list_num; static cdtime_t tail_match_list_intervals[255]; static int ctail_config_add_match_dstype(ctail_config_match_t *cm, diff --git a/src/tape.c b/src/tape.c index f59b7ea6..26bd969a 100644 --- a/src/tape.c +++ b/src/tape.c @@ -36,7 +36,7 @@ #define MAX_NUMTAPE 256 extern kstat_ctl_t *kc; static kstat_t *ksp[MAX_NUMTAPE]; -static int numtape = 0; +static int numtape; static int tape_init(void) { kstat_t *ksp_chain; diff --git a/src/tcpconns.c b/src/tcpconns.c index 07170d78..90dedce4 100644 --- a/src/tcpconns.c +++ b/src/tcpconns.c @@ -205,7 +205,7 @@ static const char *tcp_state[] = {"CLOSED", "LISTEN", "SYN_SENT", "FIN_WAIT2", "TIME_WAIT"}; static kvm_t *kvmd; -static u_long inpcbtable_off = 0; +static u_long inpcbtable_off; struct inpcbtable *inpcbtable_ptr = NULL; #define TCP_STATE_LISTEN 1 @@ -261,8 +261,8 @@ static const char *config_keys[] = {"ListeningPorts", "LocalPort", "RemotePort", "AllPortsSummary"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); -static int port_collect_listening = 0; -static int port_collect_total = 0; +static int port_collect_listening; +static int port_collect_total; static port_entry_t *port_list_head; static uint32_t count_total[TCP_STATE_MAX + 1]; @@ -271,7 +271,7 @@ static uint32_t count_total[TCP_STATE_MAX + 1]; /* This depends on linux inet_diag_req because if this structure is missing, * sequence_number is useless and we get a compilation warning. */ -static uint32_t sequence_number = 0; +static uint32_t sequence_number; #endif static enum { SRC_DUNNO, SRC_NETLINK, SRC_PROC } linux_source = SRC_DUNNO; diff --git a/src/ted.c b/src/ted.c index 21d6357b..b5fa4c1e 100644 --- a/src/ted.c +++ b/src/ted.c @@ -54,7 +54,7 @@ #define DEFAULT_DEVICE "/dev/ttyUSB0" static char *conf_device; -static int conf_retries = 0; +static int conf_retries; static int fd = -1; diff --git a/src/testing.h b/src/testing.h index 41e2e81e..5cf69559 100644 --- a/src/testing.h +++ b/src/testing.h @@ -29,8 +29,8 @@ #include -static int fail_count__ = 0; -static int check_count__ = 0; +static int fail_count__; +static int check_count__; #ifndef DBL_PRECISION #define DBL_PRECISION 1e-12 diff --git a/src/unixsock.c b/src/unixsock.c index be2af755..522271c6 100644 --- a/src/unixsock.c +++ b/src/unixsock.c @@ -55,7 +55,7 @@ static const char *config_keys[] = {"SocketFile", "SocketGroup", "SocketPerms", "DeleteSocket"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); -static int loop = 0; +static int loop; /* socket configuration */ static int sock_fd = -1; @@ -361,7 +361,7 @@ static int us_config(const char *key, const char *val) { } /* int us_config */ static int us_init(void) { - static int have_init = 0; + static int have_init; int status; diff --git a/src/utils_dns.c b/src/utils_dns.c index faa917f8..7b20e139 100644 --- a/src/utils_dns.c +++ b/src/utils_dns.c @@ -166,8 +166,8 @@ static ip_list_t *IgnoreList; #if HAVE_PCAP_H static void (*Callback)(const rfc1035_header_t *); -static int query_count_intvl = 0; -static int query_count_total = 0; +static int query_count_intvl; +static int query_count_total; #ifdef __OpenBSD__ static struct bpf_timeval last_ts; #else @@ -267,7 +267,7 @@ static int rfc1035NameUnpack(const char *buf, size_t sz, off_t *off, char *name, off_t no = 0; unsigned char c; size_t len; - static int loop_detect = 0; + static int loop_detect; if (loop_detect > 2) return 4; /* compression loop */ if (ns == 0) diff --git a/src/utils_ovs.c b/src/utils_ovs.c index 57629a01..3b7236ca 100644 --- a/src/utils_ovs.c +++ b/src/utils_ovs.c @@ -191,7 +191,7 @@ struct ovs_db_s { }; /* Global variables */ -static uint64_t ovs_uid = 0; +static uint64_t ovs_uid; static pthread_mutex_t ovs_uid_mutex = PTHREAD_MUTEX_INITIALIZER; /* Post an event to event thread. diff --git a/src/virt.c b/src/virt.c index cdb71418..12008f82 100644 --- a/src/virt.c +++ b/src/virt.c @@ -241,7 +241,7 @@ const char *domain_reasons[][DOMAIN_STATE_REASON_MAX_SIZE] = { } while (0) /* Connection. */ -static virConnectPtr conn = 0; +static virConnectPtr conn; static char *conn_string; static c_complain_t conn_complain = C_COMPLAIN_INIT_STATIC; diff --git a/src/vmem.c b/src/vmem.c index 95cfbaf1..c7229756 100644 --- a/src/vmem.c +++ b/src/vmem.c @@ -33,7 +33,7 @@ static const char *config_keys[] = {"Verbose"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); -static int verbose_output = 0; +static int verbose_output; /* #endif KERNEL_LINUX */ #else diff --git a/src/vserver.c b/src/vserver.c index f15bb3b5..3c6d58cd 100644 --- a/src/vserver.c +++ b/src/vserver.c @@ -42,7 +42,7 @@ #error "No applicable input method." #endif -static int pagesize = 0; +static int pagesize; static int vserver_init(void) { /* XXX Should we check for getpagesize () in configure? diff --git a/src/write_tsdb.c b/src/write_tsdb.c index a422f372..42f5d65b 100644 --- a/src/write_tsdb.c +++ b/src/write_tsdb.c @@ -94,8 +94,8 @@ struct wt_callback { cdtime_t next_random_ttl; }; -static cdtime_t resolve_interval = 0; -static cdtime_t resolve_jitter = 0; +static cdtime_t resolve_interval; +static cdtime_t resolve_jitter; /* * Functions -- 2.11.0