From: Ruben Kerkhof Date: Sun, 13 May 2018 16:56:18 +0000 (+0200) Subject: No need to initialize static bools to false X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f25d207699e013bb47c0083fe56b8358a98f6f4d;p=collectd.git No need to initialize static bools to false --- diff --git a/src/apcups.c b/src/apcups.c index 2fa24799..f16da90e 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -73,7 +73,7 @@ typedef struct { static char *conf_node = NULL; static char *conf_service = NULL; /* Defaults to false for backwards compatibility. */ -static bool conf_report_seconds = 0; +static bool conf_report_seconds; static bool conf_persistent_conn = 1; static int global_sockfd = -1; diff --git a/src/barometer.c b/src/barometer.c index be8198ac..f21cdafe 100644 --- a/src/barometer.c +++ b/src/barometer.c @@ -186,7 +186,7 @@ static double config_temp_offset = 0.0; /**< temperature offset */ static double config_altitude = NAN; /**< altitude */ static int config_normalize = 0; /**< normalization method */ -static bool configured = 0; /**< the whole plugin config status */ +static bool configured; /**< the whole plugin config status */ static int i2c_bus_fd = -1; /**< I2C bus device FD */ @@ -226,7 +226,7 @@ static short bmp085_MD; /* Used only for MPL115. MPL3115 supports real oversampling in the device so */ /* no need for any postprocessing. */ -static bool avg_initialized = 0; /**< already initialized by real values */ +static bool avg_initialized; /**< already initialized by real values */ typedef struct averaging_s { long int *ring_buffer; diff --git a/src/battery.c b/src/battery.c index 74e27961..0e2667c9 100644 --- a/src/battery.c +++ b/src/battery.c @@ -72,9 +72,9 @@ int battery_read_statefs( void); /* defined in battery_statefs; used by StateFS backend */ -static bool report_percent = 0; -static bool report_degraded = 0; -static bool query_statefs = 0; +static bool report_percent; +static bool report_degraded; +static bool query_statefs; static void battery_submit2(char const *plugin_instance, /* {{{ */ char const *type, char const *type_instance, diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index 27d5622f..d53ae655 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -101,7 +101,7 @@ static char *hostname_g = NULL; static range_t range_critical_g; static range_t range_warning_g; static int consolitation_g = CON_NONE; -static bool nan_is_error_g = 0; +static bool nan_is_error_g; static char **match_ds_g = NULL; static size_t match_ds_num_g = 0; diff --git a/src/cpu.c b/src/cpu.c index 42fcbed9..a0e00d74 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -196,9 +196,9 @@ static size_t global_cpu_num = 0; static bool report_by_cpu = 1; static bool report_by_state = 1; -static bool report_percent = 0; -static bool report_num_cpu = 0; -static bool report_guest = 0; +static bool report_percent; +static bool report_num_cpu; +static bool report_guest; static bool subtract_guest = 1; static const char *config_keys[] = {"ReportByCpu", "ReportByState", diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c index eb269587..3dcd9fce 100644 --- a/src/daemon/plugin.c +++ b/src/daemon/plugin.c @@ -133,13 +133,13 @@ static pthread_t *write_threads = NULL; static size_t write_threads_num = 0; static pthread_key_t plugin_ctx_key; -static bool plugin_ctx_key_initialized = 0; +static bool plugin_ctx_key_initialized; static long write_limit_high = 0; static long write_limit_low = 0; static derive_t stats_values_dropped = 0; -static bool record_statistics = 0; +static bool record_statistics; /* * Static functions diff --git a/src/daemon/utils_random.c b/src/daemon/utils_random.c index def0ba68..e3ce34cd 100644 --- a/src/daemon/utils_random.c +++ b/src/daemon/utils_random.c @@ -32,7 +32,7 @@ #include static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; -static bool have_seed = 0; +static bool have_seed; static unsigned short seed[3]; static void cdrand_seed(void) { diff --git a/src/df.c b/src/df.c index 5c08ca4a..7e4c715e 100644 --- a/src/df.c +++ b/src/df.c @@ -55,10 +55,10 @@ static ignorelist_t *il_device = NULL; static ignorelist_t *il_mountpoint = NULL; static ignorelist_t *il_fstype = NULL; -static bool by_device = 0; -static bool report_inodes = 0; +static bool by_device; +static bool report_inodes; static bool values_absolute = 1; -static bool values_percentage = 0; +static bool values_percentage; static int df_init(void) { if (il_device == NULL) diff --git a/src/disk.c b/src/disk.c index 317e1054..506c0e0a 100644 --- a/src/disk.c +++ b/src/disk.c @@ -82,7 +82,7 @@ static mach_port_t io_master_port = MACH_PORT_NULL; /* This defaults to false for backwards compatibility. Please fix in the next * major version. */ -static bool use_bsd_name = 0; +static bool use_bsd_name; /* #endif HAVE_IOKIT_IOKITLIB_H */ #elif KERNEL_LINUX diff --git a/src/ethstat.c b/src/ethstat.c index c234d7e8..316c25fc 100644 --- a/src/ethstat.c +++ b/src/ethstat.c @@ -53,7 +53,7 @@ static size_t interfaces_num = 0; static c_avl_tree_t *value_map = NULL; -static bool collect_mapped_only = 0; +static bool collect_mapped_only; static int ethstat_add_interface(const oconfig_item_t *ci) /* {{{ */ { diff --git a/src/fhcount.c b/src/fhcount.c index 1e84efa9..9e74dabd 100644 --- a/src/fhcount.c +++ b/src/fhcount.c @@ -26,7 +26,7 @@ static const char *config_keys[] = {"ValuesAbsolute", "ValuesPercentage"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); static bool values_absolute = 1; -static bool values_percentage = 0; +static bool values_percentage; static int fhcount_config(const char *key, const char *value) { int ret = -1; diff --git a/src/hugepages.c b/src/hugepages.c index 95150460..23db25bf 100644 --- a/src/hugepages.c +++ b/src/hugepages.c @@ -39,8 +39,8 @@ static bool g_flag_rpt_numa = 1; static bool g_flag_rpt_mm = 1; static bool g_values_pages = 1; -static bool g_values_bytes = 0; -static bool g_values_percent = 0; +static bool g_values_bytes; +static bool g_values_percent; #define HP_HAVE_NR 0x01 #define HP_HAVE_SURPLUS 0x02 diff --git a/src/interface.c b/src/interface.c index 64764d51..e0e08c39 100644 --- a/src/interface.c +++ b/src/interface.c @@ -98,7 +98,7 @@ static bool report_inactive = 1; extern kstat_ctl_t *kc; static kstat_t *ksp[MAX_NUMIF]; static int numif = 0; -static bool unique_name = 0; +static bool unique_name; #endif /* HAVE_LIBKSTAT */ static int interface_config(const char *key, const char *value) { diff --git a/src/libcollectdclient/network_buffer.c b/src/libcollectdclient/network_buffer.c index 755d476c..07d3e767 100644 --- a/src/libcollectdclient/network_buffer.c +++ b/src/libcollectdclient/network_buffer.c @@ -125,7 +125,7 @@ struct lcc_network_buffer_s { */ static bool have_gcrypt(void) /* {{{ */ { - static bool result = 0; + static bool result; static bool need_init = 1; if (!need_init) diff --git a/src/load.c b/src/load.c index ac07fa64..4bc93d5e 100644 --- a/src/load.c +++ b/src/load.c @@ -55,7 +55,7 @@ #include #endif /* HAVE_PERFSTAT */ -static bool report_relative_load = 0; +static bool report_relative_load; static const char *config_keys[] = {"ReportRelative"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); diff --git a/src/lpar.c b/src/lpar.c index 367ebcdc..77e6d087 100644 --- a/src/lpar.c +++ b/src/lpar.c @@ -40,10 +40,10 @@ static const char *config_keys[] = {"CpuPoolStats", "ReportBySerial"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); -static bool pool_stats = 0; -static bool report_by_serial = 0; +static bool pool_stats; +static bool report_by_serial; #if PERFSTAT_SUPPORTS_DONATION -static bool donate_flag = 0; +static bool donate_flag; #endif static char serial[SYS_NMLN]; diff --git a/src/memcached.c b/src/memcached.c index 95a9edad..45796146 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -69,7 +69,7 @@ struct memcached_s { }; typedef struct memcached_s memcached_t; -static bool memcached_have_instances = 0; +static bool memcached_have_instances; static void memcached_free(void *arg) { memcached_t *st = arg; diff --git a/src/memory.c b/src/memory.c index 336a6307..ce9ef834 100644 --- a/src/memory.c +++ b/src/memory.c @@ -95,7 +95,7 @@ static int pagesize; #endif static bool values_absolute = 1; -static bool values_percentage = 0; +static bool values_percentage; static int memory_config(oconfig_item_t *ci) /* {{{ */ { diff --git a/src/network.c b/src/network.c index 3b5a0f2d..270bed29 100644 --- a/src/network.c +++ b/src/network.c @@ -264,8 +264,8 @@ typedef struct receive_list_entry_s receive_list_entry_t; static int network_config_ttl = 0; /* Ethernet - (IPv6 + UDP) = 1500 - (40 + 8) = 1452 */ static size_t network_config_packet_size = 1452; -static bool network_config_forward = 0; -static bool network_config_stats = 0; +static bool network_config_forward; +static bool network_config_stats; static sockent_t *sending_sockets = NULL; @@ -3096,7 +3096,7 @@ static int network_stats_read(void) /* {{{ */ } /* }}} int network_stats_read */ static int network_init(void) { - static bool have_init = 0; + static bool have_init; /* Check if we were already initialized. If so, just return - there's * nothing more to do (for now, that is). */ diff --git a/src/ntpd.c b/src/ntpd.c index ffb71b03..d0cd94cb 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -61,7 +61,7 @@ static bool do_reverse_lookups = 1; /* This option only exists for backward compatibility. If it is false and two * ntpd peers use the same refclock driver, the plugin will try to write * simultaneous measurements from both to the same type instance. */ -static bool include_unit_id = 0; +static bool include_unit_id; #define NTPD_DEFAULT_HOST "localhost" #define NTPD_DEFAULT_PORT "123" diff --git a/src/onewire.c b/src/onewire.c index 65c071b5..1803d264 100644 --- a/src/onewire.c +++ b/src/onewire.c @@ -88,7 +88,7 @@ static int ow_family_features_num = STATIC_ARRAY_SIZE(ow_family_features); static char *device_g = NULL; static cdtime_t ow_interval = 0; -static bool direct_access = 0; +static bool direct_access; static const char *config_keys[] = {"Device", "IgnoreSelected", "Sensor", "Interval"}; @@ -96,7 +96,7 @@ static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); static ignorelist_t *sensor_list; -static bool regex_direct_initialized = 0; +static bool regex_direct_initialized; static regex_t regex_direct; /** diff --git a/src/openvpn.c b/src/openvpn.c index 4c3e464d..30254f0d 100644 --- a/src/openvpn.c +++ b/src/openvpn.c @@ -80,9 +80,9 @@ struct vpn_status_s { }; typedef struct vpn_status_s vpn_status_t; -static bool new_naming_schema = 0; +static bool new_naming_schema; static bool collect_compression = 1; -static bool collect_user_count = 0; +static bool collect_user_count; static bool collect_individual_users = 1; static const char *config_keys[] = { diff --git a/src/pinba.c b/src/pinba.c index 02bdcc2b..9620f1b8 100644 --- a/src/pinba.c +++ b/src/pinba.c @@ -106,8 +106,8 @@ static pthread_mutex_t stat_nodes_lock; static char *conf_node = NULL; static char *conf_service = NULL; -static bool collector_thread_running = 0; -static bool collector_thread_do_shutdown = 0; +static bool collector_thread_running; +static bool collector_thread_do_shutdown; static pthread_t collector_thread_id; /* }}} */ diff --git a/src/postgresql.c b/src/postgresql.c index 7316c547..803b63be 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -1124,7 +1124,7 @@ static int c_psql_config_database(oconfig_item_t *ci) { c_psql_database_t *db; char cb_name[DATA_MAX_NAME_LEN]; - static bool have_flush = 0; + static bool have_flush; if ((1 != ci->values_num) || (OCONFIG_TYPE_STRING != ci->values[0].type)) { log_err(" expects a single string argument."); diff --git a/src/processes.c b/src/processes.c index 8e11175a..12a63df6 100644 --- a/src/processes.c +++ b/src/processes.c @@ -296,10 +296,10 @@ typedef struct procstat { static procstat_t *list_head_g = NULL; static bool want_init = 1; -static bool report_ctx_switch = 0; -static bool report_fd_num = 0; -static bool report_maps_num = 0; -static bool report_delay = 0; +static bool report_ctx_switch; +static bool report_fd_num; +static bool report_maps_num; +static bool report_delay; #if HAVE_THREAD_INFO static mach_port_t port_host_self; diff --git a/src/python.c b/src/python.c index 178f52d2..53b3806c 100644 --- a/src/python.c +++ b/src/python.c @@ -241,7 +241,7 @@ static char CollectdError_doc[] = static pthread_t main_thread; static PyOS_sighandler_t python_sigint_handler; -static bool do_interactive = 0; +static bool do_interactive; /* This is our global thread state. Python saves some stuff in thread-local * storage. So if we allow the interpreter to run in the background diff --git a/src/sensors.c b/src/sensors.c index 4d8e9256..3969dc9a 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -158,7 +158,7 @@ typedef struct featurelist { } featurelist_t; static char *conffile = NULL; -static bool use_labels = 0; +static bool use_labels; /* #endif (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500) */ #else /* if SENSORS_API_VERSION >= 0x500 */ diff --git a/src/statsd.c b/src/statsd.c index 34ce5863..70c1a752 100644 --- a/src/statsd.c +++ b/src/statsd.c @@ -65,25 +65,25 @@ static c_avl_tree_t *metrics_tree = NULL; static pthread_mutex_t metrics_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_t network_thread; -static bool network_thread_running = 0; -static bool network_thread_shutdown = 0; +static bool network_thread_running; +static bool network_thread_shutdown; static char *conf_node = NULL; static char *conf_service = NULL; -static bool conf_delete_counters = 0; -static bool conf_delete_timers = 0; -static bool conf_delete_gauges = 0; -static bool conf_delete_sets = 0; +static bool conf_delete_counters; +static bool conf_delete_timers; +static bool conf_delete_gauges; +static bool conf_delete_sets; static double *conf_timer_percentile = NULL; -static size_t conf_timer_percentile_num = 0; +static size_t conf_timer_percentile_num; -static bool conf_counter_sum = 0; -static bool conf_timer_lower = 0; -static bool conf_timer_upper = 0; -static bool conf_timer_sum = 0; -static bool conf_timer_count = 0; +static bool conf_counter_sum; +static bool conf_timer_lower; +static bool conf_timer_upper; +static bool conf_timer_sum; +static bool conf_timer_count; /* Must hold metrics_lock when calling this function. */ static statsd_metric_t *statsd_metric_lookup_unsafe(char const *name, /* {{{ */ diff --git a/src/swap.c b/src/swap.c index 427192ad..5fdb6ea8 100644 --- a/src/swap.c +++ b/src/swap.c @@ -74,14 +74,14 @@ #if KERNEL_LINUX #define SWAP_HAVE_REPORT_BY_DEVICE 1 static derive_t pagesize; -static bool report_bytes = 0; -static bool report_by_device = 0; +static bool report_bytes; +static bool report_by_device; /* #endif KERNEL_LINUX */ #elif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS #define SWAP_HAVE_REPORT_BY_DEVICE 1 static derive_t pagesize; -static bool report_by_device = 0; +static bool report_by_device; /* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_TWO_ARGS */ #elif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS @@ -110,7 +110,7 @@ static int pagesize; #endif /* HAVE_LIBSTATGRAB */ static bool values_absolute = 1; -static bool values_percentage = 0; +static bool values_percentage; static bool report_io = 1; static int swap_config(oconfig_item_t *ci) /* {{{ */ diff --git a/src/tail_csv.c b/src/tail_csv.c index 9331142e..23281136 100644 --- a/src/tail_csv.c +++ b/src/tail_csv.c @@ -513,7 +513,7 @@ static int tcsv_config(oconfig_item_t *ci) { } /* int tcsv_config */ static int tcsv_init(void) { /* {{{ */ - static bool have_init = 0; + static bool have_init; metric_definition_t *md; if (have_init) diff --git a/src/thermal.c b/src/thermal.c index 0f7f79f8..cbd168b4 100644 --- a/src/thermal.c +++ b/src/thermal.c @@ -35,7 +35,7 @@ static const char *config_keys[] = {"Device", "IgnoreSelected", static const char *const dirname_sysfs = "/sys/class/thermal"; static const char *const dirname_procfs = "/proc/acpi/thermal_zone"; -static bool force_procfs = 0; +static bool force_procfs; static ignorelist_t *device_list; enum dev_type { TEMP = 0, COOLING_DEV }; diff --git a/src/turbostat.c b/src/turbostat.c index 5e837b81..89bf3cb5 100644 --- a/src/turbostat.c +++ b/src/turbostat.c @@ -197,8 +197,8 @@ static struct pkg_data { #define EVEN_COUNTERS thread_even, core_even, package_even static bool is_even = 1; -static bool allocated = 0; -static bool initialized = 0; +static bool allocated; +static bool initialized; #define GET_THREAD(thread_base, thread_no, core_no, pkg_no) \ (thread_base + (pkg_no)*topology.num_cores * topology.num_threads + \ diff --git a/src/unixsock.c b/src/unixsock.c index 47baffb3..67edab17 100644 --- a/src/unixsock.c +++ b/src/unixsock.c @@ -62,7 +62,7 @@ static int sock_fd = -1; static char *sock_file = NULL; static char *sock_group = NULL; static int sock_perms = S_IRWXU | S_IRWXG; -static bool delete_socket = 0; +static bool delete_socket; static pthread_t listen_thread = (pthread_t)0; diff --git a/src/utils_vl_lookup_test.c b/src/utils_vl_lookup_test.c index 8a71a3a0..d7226b97 100644 --- a/src/utils_vl_lookup_test.c +++ b/src/utils_vl_lookup_test.c @@ -29,8 +29,8 @@ #include "testing.h" #include "utils_vl_lookup.h" -static bool expect_new_obj = 0; -static bool have_new_obj = 0; +static bool expect_new_obj; +static bool have_new_obj; static lookup_identifier_t last_class_ident; static lookup_identifier_t last_obj_ident; diff --git a/src/varnish.c b/src/varnish.c index 90008827..0d939935 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -93,7 +93,7 @@ struct user_config_s { }; typedef struct user_config_s user_config_t; /* }}} */ -static bool have_instance = 0; +static bool have_instance; static int varnish_submit(const char *plugin_instance, /* {{{ */ const char *category, const char *type,