summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b599cc6)
raw | patch | inline | side by side (parent: b599cc6)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Sat, 30 Jul 2016 10:23:11 +0000 (12:23 +0200) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Mon, 1 Aug 2016 19:43:58 +0000 (21:43 +0200) |
84 files changed:
diff --git a/src/aggregation.c b/src/aggregation.c
index c4c1627af360ce463ba030cb64e80a4f6667b723..84df548511079d2afdd66eb2144b8042b6aa6074 100644 (file)
--- a/src/aggregation.c
+++ b/src/aggregation.c
char const *func, gauge_t rate, rate_to_value_state_t *state,
value_list_t *vl, char const *pi_prefix, cdtime_t t)
{
- value_t v;
+ value_t v = { 0 } ;
int status;
if (pi_prefix[0] != 0)
else
sstrncpy (vl->plugin_instance, func, sizeof (vl->plugin_instance));
- memset (&v, 0, sizeof (v));
status = rate_to_value (&v, rate, state, inst->ds_type, t);
if (status != 0)
{
diff --git a/src/amqp.c b/src/amqp.c
index 99dca9014ac628254481ca9dc451eedc21ae564d..71e38a47795b572ad75491b7e2f87af26ef6dca0 100644 (file)
--- a/src/amqp.c
+++ b/src/amqp.c
static int camqp_write_locked (camqp_config_t *conf, /* {{{ */
const char *buffer, const char *routing_key)
{
- amqp_basic_properties_t props;
+ amqp_basic_properties_t props = { 0 };
int status;
status = camqp_connect (conf);
if (status != 0)
return (status);
- memset (&props, 0, sizeof (props));
props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG
| AMQP_BASIC_DELIVERY_MODE_FLAG
| AMQP_BASIC_APP_ID_FLAG;
@@ -808,14 +807,12 @@ static int camqp_write (const data_set_t *ds, const value_list_t *vl, /* {{{ */
{
camqp_config_t *conf = user_data->data;
char routing_key[6 * DATA_MAX_NAME_LEN];
- char buffer[8192];
+ char buffer[8192] = { 0 };
int status;
if ((ds == NULL) || (vl == NULL) || (conf == NULL))
return (EINVAL);
- memset (buffer, 0, sizeof (buffer));
-
if (conf->routing_key != NULL)
{
sstrncpy (routing_key, conf->routing_key, sizeof (routing_key));
diff --git a/src/apache.c b/src/apache.c
index 40d0efe2bc3d22e093e0a2652e9fd1bd09963083..8c24a703ecb994ec7b9f1bcfc6815539471f9b75 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
if (status == 0)
{
- user_data_t ud;
- char callback_name[3*DATA_MAX_NAME_LEN];
+ user_data_t ud = { 0 };
+ char callback_name[3*DATA_MAX_NAME_LEN] = { 0 };
- memset (&ud, 0, sizeof (ud));
ud.data = st;
ud.free_func = apache_free;
- memset (callback_name, 0, sizeof (callback_name));
ssnprintf (callback_name, sizeof (callback_name),
"apache/%s/%s",
(st->host != NULL) ? st->host : hostname_g,
diff --git a/src/apcups.c b/src/apcups.c
index 9f7476bfa929940bf4bf882bfc01da764b476633..84249339a2261f7f7f6ca4f429f1d7911687c1f8 100644 (file)
--- a/src/apcups.c
+++ b/src/apcups.c
{
int sd;
int status;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_return;
struct addrinfo *ai_list;
- /* Resolve name */
- memset (&ai_hints, 0, sizeof (ai_hints));
/* TODO: Change this to `AF_UNSPEC' if apcupsd can handle IPv6 */
ai_hints.ai_family = AF_INET;
ai_hints.ai_socktype = SOCK_STREAM;
diff --git a/src/ascent.c b/src/ascent.c
index 9124c26df96fa937215d5c2db40444baab3cda2a..a947bce942ee0e045fe3a77aeadb0802fa41a725 100644 (file)
--- a/src/ascent.c
+++ b/src/ascent.c
static int ascent_xml_sessions (xmlDoc *doc, xmlNode *node) /* {{{ */
{
xmlNode *child;
- player_stats_t ps;
-
- memset (&ps, 0, sizeof (ps));
+ player_stats_t ps = {
+ .level_sum = 0
+ };
for (child = node->xmlChildrenNode; child != NULL; child = child->next)
{
diff --git a/src/bind.c b/src/bind.c
index 7d26208658b1930f823b9e33c280941e205b85cc..d46d4967caf1d9f5be590b5d383abe477daacc8d 100644 (file)
--- a/src/bind.c
+++ b/src/bind.c
xmlNode *node;
char *str_ptr;
char *tmp;
- struct tm tm;
+ struct tm tm = { 0 };
xpathObj = xmlXPathEvalExpression (BAD_CAST xpath_expression, xpathCtx);
if (xpathObj == NULL)
return (-1);
}
- memset (&tm, 0, sizeof(tm));
tmp = strptime (str_ptr, "%Y-%m-%dT%T", &tm);
xmlFree(str_ptr);
if (tmp == NULL)
diff --git a/src/ceph.c b/src/ceph.c
index 04a397434d1b7c228fc5a885a424ebbb9101c230..c34d209e08d21e5e1b9aa6b168358f2488c8f082 100644 (file)
--- a/src/ceph.c
+++ b/src/ceph.c
{
yajl_struct *state = (yajl_struct*) ctx;
char buffer[number_len+1];
- char key[2 * DATA_MAX_NAME_LEN];
+ char key[2 * DATA_MAX_NAME_LEN] = { 0 };
_Bool latency_type = 0;
size_t i;
int status;
memcpy(buffer, number_val, number_len);
buffer[sizeof(buffer) - 1] = 0;
- memset (key, 0, sizeof (key));
for (i = 0; i < state->depth; i++)
{
if (state->stack[i] == NULL)
int pc_type)
{
uint32_t type;
- char ds_name[DATA_MAX_NAME_LEN];
- memset(ds_name, 0, sizeof(ds_name));
+ char ds_name[DATA_MAX_NAME_LEN] = { 0 };
if(convert_special_metrics)
{
static int cc_add_daemon_config(oconfig_item_t *ci)
{
int ret, i;
- struct ceph_daemon *nd, cd;
+ struct ceph_daemon *nd, cd = { 0 };
struct ceph_daemon **tmp;
- memset(&cd, 0, sizeof(struct ceph_daemon));
if((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
{
uint32_t type = DSET_TYPE_UNFOUND;
int index = vtmp->index;
- char ds_name[DATA_MAX_NAME_LEN];
- memset(ds_name, 0, sizeof(ds_name));
+ char ds_name[DATA_MAX_NAME_LEN] = { 0 };
if (parse_keys (ds_name, sizeof (ds_name), key))
{
@@ -1086,7 +1082,7 @@ static int node_handler_fetch_data(void *arg, const char *val, const char *key)
static int cconn_connect(struct cconn *io)
{
- struct sockaddr_un address;
+ struct sockaddr_un address = { 0 };
int flags, fd, err;
if(io->state != CSTATE_UNCONNECTED)
{
"failed: error %d", err);
return err;
}
- memset(&address, 0, sizeof(struct sockaddr_un));
address.sun_family = AF_UNIX;
snprintf(address.sun_path, sizeof(address.sun_path), "%s",
io->d->asok_path);
diff --git a/src/chrony.c b/src/chrony.c
index 012fd9a9bcb28bb02a37ff9845a5aabb712b5342..4a09753ffc3ee2b3ee151b5841ad670dc6b86e5a 100644 (file)
--- a/src/chrony.c
+++ b/src/chrony.c
connect_client(const char *p_hostname,
const char *p_service, int p_family, int p_socktype)
{
- struct addrinfo hints, *res = NULL, *ressave = NULL;
+ struct addrinfo hints = { 0 };
+ struct addrinfo *res = NULL, *ressave = NULL;
int n, sockfd;
- memset(&hints, 0, sizeof(struct addrinfo));
-
hints.ai_family = p_family;
hints.ai_socktype = p_socktype;
}
#if COLLECT_DEBUG
{
- char src_addr[IPV6_STR_MAX_SIZE];
- memset(src_addr, 0, sizeof(src_addr));
+ char src_addr[IPV6_STR_MAX_SIZE] = { 0 };
niptoha(&chrony_resp.body.tracking.addr, src_addr, sizeof(src_addr));
DEBUG(PLUGIN_NAME ": Daemon stat: .addr = %s, .ref_id= %u, .stratum = %u, .leap_status = %u, .ref_time = %u:%u:%u, .current_correction = %f, .last_offset = %f, .rms_offset = %f, .freq_ppm = %f, .skew_ppm = %f, .root_delay = %f, .root_dispersion = %f, .last_update_interval = %f", src_addr, ntohs(chrony_resp.body.tracking.f_ref_id),
ntohs(chrony_resp.body.tracking.f_stratum),
tChrony_Request chrony_req;
tChrony_Response chrony_resp;
- char src_addr[IPV6_STR_MAX_SIZE];
- memset(src_addr, 0, sizeof(src_addr));
+ char src_addr[IPV6_STR_MAX_SIZE] = { 0 };
chrony_init_req(&chrony_req);
chrony_req.body.source_data.f_index = htonl(p_src_idx);
tChrony_Response chrony_resp;
double skew_ppm, frequency_error, time_offset;
- char src_addr[IPV6_STR_MAX_SIZE];
- memset(src_addr, 0, sizeof(src_addr));
+ char src_addr[IPV6_STR_MAX_SIZE] = { 0 };
if (*p_is_reachable == 0)
{
diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c
index dd90737f6f3a4063685bdd27072d9fb4bd94cd9c..c1a851568a9aa419d63980ce685c4506ce4dc42d 100644 (file)
--- a/src/collectd-nagios.c
+++ b/src/collectd-nagios.c
hostname_g, value_string_g);
ident_str[sizeof (ident_str) - 1] = 0;
- memset (&ident, 0, sizeof (ident));
status = lcc_string_to_identifier (connection, &ident, ident_str);
if (status != 0)
{
diff --git a/src/collectdctl.c b/src/collectdctl.c
index 18b39173e5c018643bac4a665d242ff008a75879..8ca0559d0728eebf5dafabb57fb0c47e556e29aa 100644 (file)
--- a/src/collectdctl.c
+++ b/src/collectdctl.c
return (-1);
}
- memset (&ident, 0, sizeof (ident));
status = parse_identifier (c, argv[1], &ident);
if (status != 0)
return (status);
diff --git a/src/conntrack.c b/src/conntrack.c
index 486b001148b05f8127a44036877cb073042989fe..123ff5431c9d1b27eb27718d5a612c70243aee41 100644 (file)
--- a/src/conntrack.c
+++ b/src/conntrack.c
{
value_t conntrack, conntrack_max, conntrack_pct;
FILE *fh;
- char buffer[64];
+ char buffer[64] = { 0 };
size_t buffer_len;
fh = fopen (old_files?CONNTRACK_FILE_OLD:CONNTRACK_FILE, "r");
if (fh == NULL)
return (-1);
- memset (buffer, 0, sizeof (buffer));
if (fgets (buffer, sizeof (buffer), fh) == NULL)
{
fclose (fh);
diff --git a/src/csv.c b/src/csv.c
index 7b513e7345199a508fc53531187aac959784c74b..0cb9bc1a319f9e33f1903f601266e6954c720f44 100644 (file)
--- a/src/csv.c
+++ b/src/csv.c
char values[4096];
FILE *csv;
int csv_fd;
- struct flock fl;
+ struct flock fl = { 0 };
int status;
if (0 != strcmp (ds->type, vl->type)) {
}
csv_fd = fileno (csv);
- memset (&fl, '\0', sizeof (fl));
- fl.l_start = 0;
- fl.l_len = 0; /* till end of file */
fl.l_pid = getpid ();
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
diff --git a/src/curl_json.c b/src/curl_json.c
index 55db3877f00a42bc4a8cfc4b850afa20f335a441..2dac7479308df41485226c947d03739d2c394d4f 100644 (file)
--- a/src/curl_json.c
+++ b/src/curl_json.c
/* If all went well, register this database for reading */
if (status == 0)
{
- user_data_t ud;
+ user_data_t ud = { 0 };
char *cb_name;
if (db->instance == NULL)
DEBUG ("curl_json plugin: Registering new read callback: %s",
db->instance);
- memset (&ud, 0, sizeof (ud));
ud.data = (void *) db;
ud.free_func = cj_free;
diff --git a/src/curl_xml.c b/src/curl_xml.c
index e0e4a62ff1d00bd5a1056b5869b658f43e5832b7..05d75c670b60d4419e0657bd26d9567bc80af528 100644 (file)
--- a/src/curl_xml.c
+++ b/src/curl_xml.c
/* If all went well, register this database for reading */
if (status == 0)
{
- user_data_t ud;
+ user_data_t ud = { 0 };
char *cb_name;
if (db->instance == NULL)
DEBUG ("curl_xml plugin: Registering new read callback: %s",
db->instance);
- memset (&ud, 0, sizeof (ud));
ud.data = (void *) db;
ud.free_func = cx_free;
diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c
index 2fce643d8d83113b8090cb16aa024786f4a6829e..840520887b3352a70dc19d6243b9c8fe58f81430 100644 (file)
--- a/src/daemon/collectd.c
+++ b/src/daemon/collectd.c
{
const char *str;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
int status;
if (IS_FALSE (str))
return (0);
- memset (&ai_hints, '\0', sizeof (ai_hints));
ai_hints.ai_flags = AI_CANONNAME;
status = getaddrinfo (hostname_g, NULL, &ai_hints, &ai_list);
{
int fd;
const char *notifysocket;
- struct sockaddr_un su;
+ struct sockaddr_un su = { 0 };
size_t su_size;
char buffer[] = "READY=1\n";
return 0;
}
- memset (&su, 0, sizeof (su));
su.sun_family = AF_UNIX;
if (notifysocket[0] != '@')
{
int main (int argc, char **argv)
{
- struct sigaction sig_int_action;
- struct sigaction sig_term_action;
- struct sigaction sig_usr1_action;
- struct sigaction sig_pipe_action;
const char *configfile = CONFIGFILE;
int test_config = 0;
int test_readall = 0;
const char *basedir;
#if COLLECT_DAEMON
- struct sigaction sig_chld_action;
pid_t pid;
int daemonize = 1;
#endif
/*
* fork off child
*/
- memset (&sig_chld_action, '\0', sizeof (sig_chld_action));
- sig_chld_action.sa_handler = SIG_IGN;
+ struct sigaction sig_chld_action = {
+ .sa_handler = SIG_IGN
+ };
+
sigaction (SIGCHLD, &sig_chld_action, NULL);
/*
} /* if (daemonize) */
#endif /* COLLECT_DAEMON */
- memset (&sig_pipe_action, '\0', sizeof (sig_pipe_action));
- sig_pipe_action.sa_handler = SIG_IGN;
+ struct sigaction sig_pipe_action = {
+ .sa_handler = SIG_IGN
+ };
+
sigaction (SIGPIPE, &sig_pipe_action, NULL);
/*
* install signal handlers
*/
- memset (&sig_int_action, '\0', sizeof (sig_int_action));
- sig_int_action.sa_handler = sig_int_handler;
+ struct sigaction sig_int_action = {
+ .sa_handler = sig_int_handler
+ };
+
if (0 != sigaction (SIGINT, &sig_int_action, NULL)) {
char errbuf[1024];
ERROR ("Error: Failed to install a signal handler for signal INT: %s",
return (1);
}
- memset (&sig_term_action, '\0', sizeof (sig_term_action));
- sig_term_action.sa_handler = sig_term_handler;
+ struct sigaction sig_term_action = {
+ .sa_handler = sig_term_handler
+ };
+
if (0 != sigaction (SIGTERM, &sig_term_action, NULL)) {
char errbuf[1024];
ERROR ("Error: Failed to install a signal handler for signal TERM: %s",
return (1);
}
- memset (&sig_usr1_action, '\0', sizeof (sig_usr1_action));
- sig_usr1_action.sa_handler = sig_usr1_handler;
+ struct sigaction sig_usr1_action = {
+ .sa_handler = sig_usr1_handler
+ };
+
if (0 != sigaction (SIGUSR1, &sig_usr1_action, NULL)) {
char errbuf[1024];
ERROR ("Error: Failed to install a signal handler for signal USR1: %s",
diff --git a/src/daemon/common.c b/src/daemon/common.c
index f9b1433b3a5d86f6004c015f79b8206cfc854403..9da47755034038ebc0025343b9e3b55a6b2f1796 100644 (file)
--- a/src/daemon/common.c
+++ b/src/daemon/common.c
{
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
int status;
int service_number;
return (-1);
ai_list = NULL;
- memset (&ai_hints, 0, sizeof (ai_hints));
ai_hints.ai_family = AF_UNSPEC;
status = getaddrinfo (/* node = */ NULL, service_name,
index b9860bd9b96878534b5ec5849914f47a0ba0f574..0654ad7edf825839dc702a98d28d5fd2b6da92fe 100644 (file)
--- a/src/daemon/configfile.c
+++ b/src/daemon/configfile.c
int i;
const char *name;
unsigned int flags = 0;
- plugin_ctx_t ctx;
+ plugin_ctx_t ctx = { 0 };
plugin_ctx_t old_ctx;
int ret_val;
name = "virt";
/* default to the global interval set before loading this plugin */
- memset (&ctx, 0, sizeof (ctx));
ctx.interval = cf_get_default_interval ();
ctx.flush_interval = 0;
ctx.flush_timeout = 0;
if (IS_TRUE (global_option_get ("AutoLoadPlugin")))
{
- plugin_ctx_t ctx;
+ plugin_ctx_t ctx = { 0 };
plugin_ctx_t old_ctx;
int status;
/* default to the global interval set before loading this plugin */
- memset (&ctx, 0, sizeof (ctx));
ctx.interval = cf_get_default_interval ();
old_ctx = plugin_set_ctx (ctx);
index a622af961dcf281b557c14634d9ef041a8d10175..c10525de37f21694e13c118208c4cf2084420d40 100644 (file)
static int fc_init_once (void) /* {{{ */
{
static int done = 0;
- target_proc_t tproc;
+ target_proc_t tproc = { 0 };
if (done != 0)
return (0);
- memset (&tproc, 0, sizeof (tproc));
tproc.create = fc_bit_jump_create;
tproc.destroy = fc_bit_jump_destroy;
tproc.invoke = fc_bit_jump_invoke;
index cf87b6b7782b7bc5aa461163d6adeed4f1285f9e..b4cd5171c1a573a095fa605216b994ac5d9e0534 100644 (file)
--- a/src/daemon/utils_match.c
+++ b/src/daemon/utils_match.c
{
int status;
regmatch_t re_match[32];
- char *matches[32];
+ char *matches[32] = { 0 };
size_t matches_num;
size_t i;
if (status != 0)
return (0);
- memset (matches, '\0', sizeof (matches));
for (matches_num = 0; matches_num < STATIC_ARRAY_SIZE (matches); matches_num++)
{
if ((re_match[matches_num].rm_so < 0)
index 0b0a8fb41ce9a1064d3d4b27cc9f37c34000e82a..a6fb600597d98621619af2451caca31e54675add 100644 (file)
--- a/src/daemon/utils_tail.c
+++ b/src/daemon/utils_tail.c
{
int seek_end = 0;
FILE *fh;
- struct stat stat_buf;
+ struct stat stat_buf = { 0 };
int status;
- memset (&stat_buf, 0, sizeof (stat_buf));
status = stat (obj->file, &stat_buf);
if (status != 0)
{
diff --git a/src/dbi.c b/src/dbi.c
index 273cce8e1eae7d5177bcee06bfee08da3ce542eb..d5a6c603161b4a12743e70e3f9fe72a7781d56b2 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
}
else
{
- user_data_t ud;
+ user_data_t ud = { 0 };
char *name = NULL;
databases = temp;
databases[databases_num] = db;
databases_num++;
- memset (&ud, 0, sizeof (ud));
ud.data = (void *) db;
ud.free_func = NULL;
name = ssnprintf_alloc("dbi:%s", db->name);
diff --git a/src/dns.c b/src/dns.c
index 2c3a90436da56e17196bcdde7ed245ac575d03a9..5930dc5033ad85e74ae0f01a5d592a0086f71ad0 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
{
pcap_t *pcap_obj;
char pcap_error[PCAP_ERRBUF_SIZE];
- struct bpf_program fp;
+ struct bpf_program fp = { 0 };
int status;
return (PCAP_ERROR);
}
- memset (&fp, 0, sizeof (fp));
status = pcap_compile (pcap_obj, &fp, "udp port 53", 1, 0);
if (status < 0)
{
diff --git a/src/ethstat.c b/src/ethstat.c
index 959737a368add51263a93c1caf6fb9cab4b7c3bb..b30f614eab93460d7db4cc87d68d67c71d046b7f 100644 (file)
--- a/src/ethstat.c
+++ b/src/ethstat.c
static int ethstat_read_interface (char *device)
{
int fd;
- struct ifreq req;
- struct ethtool_drvinfo drvinfo;
struct ethtool_gstrings *strings;
struct ethtool_stats *stats;
size_t n_stats;
size_t i;
int status;
- memset (&req, 0, sizeof (req));
- sstrncpy(req.ifr_name, device, sizeof (req.ifr_name));
-
fd = socket(AF_INET, SOCK_DGRAM, /* protocol = */ 0);
if (fd < 0)
{
return 1;
}
- memset (&drvinfo, 0, sizeof (drvinfo));
- drvinfo.cmd = ETHTOOL_GDRVINFO;
- req.ifr_data = (void *) &drvinfo;
+ struct ethtool_drvinfo drvinfo = {
+ .cmd = ETHTOOL_GDRVINFO
+ };
+
+ struct ifreq req = {
+ .ifr_data = (void *) &drvinfo
+ };
+
+ sstrncpy(req.ifr_name, device, sizeof (req.ifr_name));
+
status = ioctl (fd, SIOCETHTOOL, &req);
if (status < 0)
{
diff --git a/src/exec.c b/src/exec.c
index cdaf79a0b04e741aee314aafb90921ff1fe0ef9b..71a49181b781ad2d9240263084b33fa6b07b0ee8 100644 (file)
--- a/src/exec.c
+++ b/src/exec.c
{
sigset_t ss;
- memset (&ss, 0, sizeof (ss));
sigemptyset (&ss);
sigprocmask (SIG_SETMASK, &ss, /* old mask = */ NULL);
} /* }}} void reset_signal_mask */
static int exec_init (void) /* {{{ */
{
- struct sigaction sa;
+ struct sigaction sa = {
+ .sa_handler = sigchld_handler
+ };
- memset (&sa, '\0', sizeof (sa));
- sa.sa_handler = sigchld_handler;
sigaction (SIGCHLD, &sa, NULL);
return (0);
diff --git a/src/gmond.c b/src/gmond.c
index 728162ec608c6ef76e36e15751608245390de4ad..47158c975b800b823926e325200a85a18de4fa4d 100644 (file)
--- a/src/gmond.c
+++ b/src/gmond.c
size_t *ret_sockets_num,
const char *node, const char *service, int listen)
{
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
int ai_return;
if (*ret_sockets != NULL)
return (EINVAL);
- memset (&ai_hints, 0, sizeof (ai_hints));
- ai_hints.ai_flags = 0;
#ifdef AI_PASSIVE
ai_hints.ai_flags |= AI_PASSIVE;
#endif
if (ai_ptr->ai_family == AF_INET)
{
struct sockaddr_in *addr;
- struct ip_mreq mreq;
int loop;
addr = (struct sockaddr_in *) ai_ptr->ai_addr;
sstrerror (errno, errbuf, sizeof (errbuf)));
}
- memset (&mreq, 0, sizeof (mreq));
- mreq.imr_multiaddr.s_addr = addr->sin_addr.s_addr;
- mreq.imr_interface.s_addr = htonl (INADDR_ANY);
+ struct ip_mreq mreq = {
+ .imr_multiaddr.s_addr = addr->sin_addr.s_addr,
+ .imr_interface.s_addr = htonl (INADDR_ANY)
+ };
status = setsockopt (sockets[sockets_num].fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(void *) &mreq, sizeof (mreq));
else if (ai_ptr->ai_family == AF_INET6)
{
struct sockaddr_in6 *addr;
- struct ipv6_mreq mreq;
int loop;
addr = (struct sockaddr_in6 *) ai_ptr->ai_addr;
sstrerror (errno, errbuf, sizeof (errbuf)));
}
- memset (&mreq, 0, sizeof (mreq));
+ struct ipv6_mreq mreq = {
+ .ipv6mr_interface = 0 /* any */
+ };
+
memcpy (&mreq.ipv6mr_multiaddr,
&addr->sin6_addr, sizeof (addr->sin6_addr));
- mreq.ipv6mr_interface = 0; /* any */
status = setsockopt (sockets[sockets_num].fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP,
(void *) &mreq, sizeof (mreq));
if (status != 0)
static int request_meta_data (const char *host, const char *name) /* {{{ */
{
- Ganglia_metadata_msg msg;
- char buffer[BUFF_SIZE];
+ Ganglia_metadata_msg msg = { 0 };
+ char buffer[BUFF_SIZE] = { 0 };
unsigned int buffer_size;
XDR xdr;
size_t i;
- memset (&msg, 0, sizeof (msg));
-
msg.id = gmetadata_request;
msg.Ganglia_metadata_msg_u.grequest.metric_id.host = strdup (host);
msg.Ganglia_metadata_msg_u.grequest.metric_id.name = strdup (name);
return (-1);
}
- memset (buffer, 0, sizeof (buffer));
xdrmem_create (&xdr, buffer, sizeof (buffer), XDR_ENCODE);
if (!xdr_Ganglia_metadata_msg (&xdr, &msg))
case gmetric_float:
case gmetric_double:
{
- Ganglia_value_msg msg;
+ Ganglia_value_msg msg = { 0 };
- memset (&msg, 0, sizeof (msg));
if (xdr_Ganglia_value_msg (&xdr, &msg))
mc_handle_value_msg (&msg);
break;
case gmetadata_full:
case gmetadata_request:
{
- Ganglia_metadata_msg msg;
- memset (&msg, 0, sizeof (msg));
+ Ganglia_metadata_msg msg = { 0 };
if (xdr_Ganglia_metadata_msg (&xdr, &msg))
mc_handle_metadata_msg (&msg);
break;
diff --git a/src/hddtemp.c b/src/hddtemp.c
index 3de18fd91354d166a58beff919d4b38e65e0fe33..c32aa35827744f433fe6280854b3e658c5c170ff 100644 (file)
--- a/src/hddtemp.c
+++ b/src/hddtemp.c
const char *host;
const char *port;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list, *ai_ptr;
int ai_return;
- memset (&ai_hints, '\0', sizeof (ai_hints));
- ai_hints.ai_flags = 0;
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
diff --git a/src/ipmi.c b/src/ipmi.c
index c3aa5587e48e231cadf7b7d2db6d741ab26b0daf..8b957e50584d932b9dda3cfc6a1a76ed493c4714 100644 (file)
--- a/src/ipmi.c
+++ b/src/ipmi.c
*/
static void c_ipmi_error (const char *func, int status)
{
- char errbuf[4096];
-
- memset (errbuf, 0, sizeof (errbuf));
+ char errbuf[4096] = { 0 };
if (IPMI_IS_OS_ERR (status))
{
c_ipmi_sensor_list_t *list_item;
c_ipmi_sensor_list_t *list_prev;
- char buffer[DATA_MAX_NAME_LEN];
+ char buffer[DATA_MAX_NAME_LEN] = { 0 };
const char *entity_id_string;
char sensor_name[DATA_MAX_NAME_LEN];
char *sensor_name_ptr;
sensor_id = ipmi_sensor_convert_to_id (sensor);
- memset (buffer, 0, sizeof (buffer));
ipmi_sensor_get_name (sensor, buffer, sizeof (buffer));
buffer[sizeof (buffer) - 1] = 0;
static int thread_init (os_handler_t **ret_os_handler)
{
os_handler_t *os_handler;
- ipmi_open_option_t open_option[1];
+ ipmi_open_option_t open_option[1] = { 0 };
ipmi_con_t *smi_connection = NULL;
ipmi_domain_id_t domain_id;
int status;
return (-1);
}
- memset (open_option, 0, sizeof (open_option));
open_option[0].option = IPMI_OPEN_OPTION_ALL;
open_option[0].ival = 1;
diff --git a/src/iptables.c b/src/iptables.c
index 0103725fa4a343fa712043a8f1a2162fd21a104e..20dce658b95e4edd1767a4b36e341e1308ea7759 100644 (file)
--- a/src/iptables.c
+++ b/src/iptables.c
else
return (1);
- ip_chain_t temp, *final, **list;
+ ip_chain_t temp = { 0 };
+ ip_chain_t *final, **list;
char *table;
int table_len;
char *chain;
char *fields[4];
int fields_num;
- memset (&temp, 0, sizeof (temp));
-
value_copy = strdup (value);
if (value_copy == NULL)
{
diff --git a/src/java.c b/src/java.c
index 01dc1b8ab006c48da164b6c2bc6ecde3b7b71668..33d0504c129e7aebd23e08c93efc0ad27470ce07 100644 (file)
--- a/src/java.c
+++ b/src/java.c
static jint JNICALL cjni_api_dispatch_notification (JNIEnv *jvm_env, /* {{{ */
jobject this, jobject o_notification)
{
- notification_t n;
+ notification_t n = { 0 };
int status;
- memset (&n, 0, sizeof (n));
- n.meta = NULL;
-
status = jtoc_notification (jvm_env, &n, o_notification);
if (status != 0)
{
static jint JNICALL cjni_api_register_read (JNIEnv *jvm_env, /* {{{ */
jobject this, jobject o_name, jobject o_read)
{
- user_data_t ud;
+ user_data_t ud = { 0 };
cjni_callback_info_t *cbi;
cbi = cjni_callback_info_create (jvm_env, o_name, o_read, CB_TYPE_READ);
DEBUG ("java plugin: Registering new read callback: %s", cbi->name);
- memset (&ud, 0, sizeof (ud));
ud.data = (void *) cbi;
ud.free_func = cjni_callback_info_destroy;
static jint JNICALL cjni_api_register_write (JNIEnv *jvm_env, /* {{{ */
jobject this, jobject o_name, jobject o_write)
{
- user_data_t ud;
+ user_data_t ud = { 0 };
cjni_callback_info_t *cbi;
cbi = cjni_callback_info_create (jvm_env, o_name, o_write, CB_TYPE_WRITE);
DEBUG ("java plugin: Registering new write callback: %s", cbi->name);
- memset (&ud, 0, sizeof (ud));
ud.data = (void *) cbi;
ud.free_func = cjni_callback_info_destroy;
static jint JNICALL cjni_api_register_flush (JNIEnv *jvm_env, /* {{{ */
jobject this, jobject o_name, jobject o_flush)
{
- user_data_t ud;
+ user_data_t ud = { 0 };
cjni_callback_info_t *cbi;
cbi = cjni_callback_info_create (jvm_env, o_name, o_flush, CB_TYPE_FLUSH);
DEBUG ("java plugin: Registering new flush callback: %s", cbi->name);
- memset (&ud, 0, sizeof (ud));
ud.data = (void *) cbi;
ud.free_func = cjni_callback_info_destroy;
static jint JNICALL cjni_api_register_log (JNIEnv *jvm_env, /* {{{ */
jobject this, jobject o_name, jobject o_log)
{
- user_data_t ud;
+ user_data_t ud = { 0 };
cjni_callback_info_t *cbi;
cbi = cjni_callback_info_create (jvm_env, o_name, o_log, CB_TYPE_LOG);
DEBUG ("java plugin: Registering new log callback: %s", cbi->name);
- memset (&ud, 0, sizeof (ud));
ud.data = (void *) cbi;
ud.free_func = cjni_callback_info_destroy;
static jint JNICALL cjni_api_register_notification (JNIEnv *jvm_env, /* {{{ */
jobject this, jobject o_name, jobject o_notification)
{
- user_data_t ud;
+ user_data_t ud = { 0 };
cjni_callback_info_t *cbi;
cbi = cjni_callback_info_create (jvm_env, o_name, o_notification,
@@ -1533,7 +1526,6 @@ static jint JNICALL cjni_api_register_notification (JNIEnv *jvm_env, /* {{{ */
DEBUG ("java plugin: Registering new notification callback: %s", cbi->name);
- memset (&ud, 0, sizeof (ud));
ud.data = (void *) cbi;
ud.free_func = cjni_callback_info_destroy;
@@ -1567,9 +1559,8 @@ static jint JNICALL cjni_api_register_match_target (JNIEnv *jvm_env, /* {{{ */
if (type == CB_TYPE_MATCH)
{
- match_proc_t m_proc;
+ match_proc_t m_proc = { 0 };
- memset (&m_proc, 0, sizeof (m_proc));
m_proc.create = cjni_match_target_create;
m_proc.destroy = cjni_match_target_destroy;
m_proc.match = (void *) cjni_match_target_invoke;
@@ -1578,9 +1569,8 @@ static jint JNICALL cjni_api_register_match_target (JNIEnv *jvm_env, /* {{{ */
}
else if (type == CB_TYPE_TARGET)
{
- target_proc_t t_proc;
+ target_proc_t t_proc = { 0 };
- memset (&t_proc, 0, sizeof (t_proc));
t_proc.create = cjni_match_target_create;
t_proc.destroy = cjni_match_target_destroy;
t_proc.invoke = cjni_match_target_invoke;
static int cjni_create_jvm (void) /* {{{ */
{
JNIEnv *jvm_env;
- JavaVMInitArgs vm_args;
+ JavaVMInitArgs vm_args = { 0 };
JavaVMOption vm_options[jvm_argc];
int status;
jvm_env = NULL;
- memset (&vm_args, 0, sizeof (vm_args));
vm_args.version = JNI_VERSION_1_2;
vm_args.options = vm_options;
vm_args.nOptions = (jint) jvm_argc;
else
{
int status;
- JavaVMAttachArgs args;
+ JavaVMAttachArgs args = { 0 };
assert (cjni_env->jvm_env == NULL);
- memset (&args, 0, sizeof (args));
args.version = JNI_VERSION_1_2;
status = (*jvm)->AttachCurrentThread (jvm, (void *) &jvm_env, (void *) &args);
* `value_list_t'. */
if (cbi->type == CB_TYPE_TARGET)
{
- value_list_t new_vl;
+ value_list_t new_vl = { 0 };
- memset (&new_vl, 0, sizeof (new_vl));
status = jtoc_value_list (jvm_env, &new_vl, o_vl);
if (status != 0)
{
static int cjni_shutdown (void) /* {{{ */
{
JNIEnv *jvm_env;
- JavaVMAttachArgs args;
+ JavaVMAttachArgs args = { 0 };
int status;
size_t i;
return (0);
jvm_env = NULL;
- memset (&args, 0, sizeof (args));
args.version = JNI_VERSION_1_2;
status = (*jvm)->AttachCurrentThread (jvm, (void *) &jvm_env, &args);
index 77fd576ee5d5703c304c22da4ce28928849554fb..f5eda6d2222957400258ada8e353422997ddd2b0 100644 (file)
static int lcc_receive (lcc_connection_t *c, /* {{{ */
lcc_response_t *ret_res)
{
- lcc_response_t res;
+ lcc_response_t res = { 0 };
char *ptr;
char buffer[4096];
size_t i;
- memset (&res, 0, sizeof (res));
-
/* Read the first line, containing the status and a message */
ptr = fgets (buffer, sizeof (buffer), c->fh);
if (ptr == NULL)
static int lcc_sendreceive (lcc_connection_t *c, /* {{{ */
const char *command, lcc_response_t *ret_res)
{
- lcc_response_t res;
+ lcc_response_t res = { 0 };
int status;
if (c->fh == NULL)
if (status != 0)
return (status);
- memset (&res, 0, sizeof (res));
status = lcc_receive (c, &res);
if (status == 0)
memcpy (ret_res, &res, sizeof (*ret_res));
static int lcc_open_unixsocket (lcc_connection_t *c, const char *path) /* {{{ */
{
- struct sockaddr_un sa;
+ struct sockaddr_un sa = { 0 };
int fd;
int status;
@@ -398,7 +395,6 @@ static int lcc_open_unixsocket (lcc_connection_t *c, const char *path) /* {{{ */
return (-1);
}
- memset (&sa, 0, sizeof (sa));
sa.sun_family = AF_UNIX;
strncpy (sa.sun_path, path, sizeof (sa.sun_path) - 1);
@@ -424,7 +420,7 @@ static int lcc_open_unixsocket (lcc_connection_t *c, const char *path) /* {{{ */
static int lcc_open_netsocket (lcc_connection_t *c, /* {{{ */
const char *addr_orig)
{
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_res;
struct addrinfo *ai_ptr;
char addr_copy[NI_MAXHOST];
addr_copy[sizeof(addr_copy) - 1] = '\0';
addr = addr_copy;
- memset (&ai_hints, 0, sizeof (ai_hints));
- ai_hints.ai_flags = 0;
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
index 4564fbbe9158c03437f8d81711c4c0ca5e8ce1dd..1a6c0f15abe2521bceaf04f966adc1a988b77b12 100644 (file)
static int server_send_buffer (lcc_server_t *srv) /* {{{ */
{
- char buffer[LCC_NETWORK_BUFFER_SIZE_DEFAULT];
+ char buffer[LCC_NETWORK_BUFFER_SIZE_DEFAULT] = { 0 };
size_t buffer_size;
int status;
return (status);
}
- memset (buffer, 0, sizeof (buffer));
buffer_size = sizeof (buffer);
status = lcc_network_buffer_finalize (srv->buffer);
@@ -413,18 +412,16 @@ int lcc_server_set_interface (lcc_server_t *srv, char const *interface) /* {{{ *
* index is preferred here, because of its similarity
* to the way IPv6 handles this. Unfortunately, it
* appears not to be portable. */
- struct ip_mreqn mreq;
-
- memset (&mreq, 0, sizeof (mreq));
- mreq.imr_multiaddr.s_addr = addr->sin_addr.s_addr;
- mreq.imr_address.s_addr = ntohl (INADDR_ANY);
- mreq.imr_ifindex = (int) if_index;
+ struct ip_mreqn mreq = {
+ .imr_multiaddr.s_addr = addr->sin_addr.s_addr,
+ .imr_address.s_addr = ntohl (INADDR_ANY),
+ .imr_ifindex = (int) if_index
+ };
#else
- struct ip_mreq mreq;
-
- memset (&mreq, 0, sizeof (mreq));
- mreq.imr_multiaddr.s_addr = addr->sin_addr.s_addr;
- mreq.imr_interface.s_addr = ntohl (INADDR_ANY);
+ struct ip_mreq mreq = {
+ .imr_multiaddr.s_addr = addr->sin_addr.s_addr,
+ .imr_interface.s_addr = ntohl (INADDR_ANY)
+ }
#endif
status = setsockopt (srv->fd, IPPROTO_IP, IP_MULTICAST_IF,
index 49f5576f73024e8ec3f84ff0b29e26e57c1cd599..9a9c89acccd763e2f46812eb45a8fdb844091272 100644 (file)
uint16_t pkg_type = htons (TYPE_ENCR_AES256);
uint16_t pkg_length = 0; /* Filled in in finalize. */
uint16_t pkg_user_len = htons ((uint16_t) username_length);
- char hash[20];
+ /* Filled in in finalize. */
+ char hash[20] = { 0 };
nb->encr_header_len = username_length;
nb->encr_header_len += PART_ENCRYPTION_AES256_SIZE;
gcry_randomize ((void *) &nb->encr_iv, sizeof (nb->encr_iv),
GCRY_STRONG_RANDOM);
- /* Filled in in finalize. */
- memset (hash, 0, sizeof (hash));
-
ADD_STATIC (nb, pkg_type);
ADD_STATIC (nb, pkg_length);
ADD_STATIC (nb, pkg_user_len);
diff --git a/src/madwifi.c b/src/madwifi.c
index 6eb12dd26d275e287746199b32eeff2ee9ff7ba5..ffc815da70a95f8def3a6bca994824cc23decc4d 100644 (file)
--- a/src/madwifi.c
+++ b/src/madwifi.c
static int
process_station (int sk, const char *dev, struct ieee80211req_sta_info *si)
{
- struct iwreq iwr;
static char mac[DATA_MAX_NAME_LEN];
struct ieee80211req_sta_stats stats;
const struct ieee80211_nodestats *ns = &stats.is_stats;
if (item_watched (STAT_NODE_RSSI))
submit_gauge (dev, "node_rssi", mac, NULL, si->isi_rssi);
- memset (&iwr, 0, sizeof (iwr));
+ struct iwreq iwr = {
+ .u.data.pointer = (void *) &stats,
+ .u.data.length = sizeof (stats)
+ };
sstrncpy(iwr.ifr_name, dev, sizeof (iwr.ifr_name));
- iwr.u.data.pointer = (void *) &stats;
- iwr.u.data.length = sizeof (stats);
+
memcpy(stats.is_u.macaddr, si->isi_macaddr, IEEE80211_ADDR_LEN);
status = ioctl(sk, IEEE80211_IOCTL_STA_STATS, &iwr);
if (status < 0)
process_stations (int sk, const char *dev)
{
uint8_t buf[24*1024];
- struct iwreq iwr;
uint8_t *cp;
int nodes;
size_t len;
int status;
- memset (&iwr, 0, sizeof (iwr));
+ struct iwreq iwr = {
+ .u.data.pointer = (void *) buf,
+ .u.data.length = sizeof (buf)
+ };
sstrncpy (iwr.ifr_name, dev, sizeof (iwr.ifr_name));
- iwr.u.data.pointer = (void *) buf;
- iwr.u.data.length = sizeof (buf);
status = ioctl (sk, IEEE80211_IOCTL_STA_INFO, &iwr);
if (status < 0)
diff --git a/src/match_hashed.c b/src/match_hashed.c
index 79f79face14d6bc35bd856c51de8f41f92dd6ea6..a42439c04bea05c0734a45e58188869f9e7ef279 100644 (file)
--- a/src/match_hashed.c
+++ b/src/match_hashed.c
void module_register (void)
{
- match_proc_t mproc;
+ match_proc_t mproc = { 0 };
- memset (&mproc, 0, sizeof (mproc));
mproc.create = mh_create;
mproc.destroy = mh_destroy;
mproc.match = mh_match;
diff --git a/src/match_regex.c b/src/match_regex.c
index bbc35cd4c1284770d12840e8706040c7bbd00132..2dee9a8fc39b4afa59c7a5dfadaed0c7ecf36632 100644 (file)
--- a/src/match_regex.c
+++ b/src/match_regex.c
void module_register (void)
{
- match_proc_t mproc;
+ match_proc_t mproc = { 0 };
- memset (&mproc, 0, sizeof (mproc));
mproc.create = mr_create;
mproc.destroy = mr_destroy;
mproc.match = mr_match;
diff --git a/src/match_timediff.c b/src/match_timediff.c
index 750817be129b1db04ef64c4dd8956822c0338985..3b154150aac1aae6c06f491bc7ab3a32e89d808e 100644 (file)
--- a/src/match_timediff.c
+++ b/src/match_timediff.c
void module_register (void)
{
- match_proc_t mproc;
+ match_proc_t mproc = { 0 };
- memset (&mproc, 0, sizeof (mproc));
mproc.create = mt_create;
mproc.destroy = mt_destroy;
mproc.match = mt_match;
diff --git a/src/match_value.c b/src/match_value.c
index 599f1cfb4bc6863b8432400b25cf18c7b6f2bc33..3b269c8c9c061ff77a7ddf7b7bc9a53af3c58dc4 100644 (file)
--- a/src/match_value.c
+++ b/src/match_value.c
void module_register (void)
{
- match_proc_t mproc;
+ match_proc_t mproc = { 0 };
- memset (&mproc, 0, sizeof (mproc));
mproc.create = mv_create;
mproc.destroy = mv_destroy;
mproc.match = mv_match;
diff --git a/src/mbmon.c b/src/mbmon.c
index 2d6d77e21474c274af56c7c9e2cdcd7e41575af2..ccececd758b3971756c999c231dad971e923d27a 100644 (file)
--- a/src/mbmon.c
+++ b/src/mbmon.c
const char *host;
const char *port;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list, *ai_ptr;
int ai_return;
- memset (&ai_hints, '\0', sizeof (ai_hints));
- ai_hints.ai_flags = 0;
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
diff --git a/src/memcached.c b/src/memcached.c
index 54e3a1904ba43f178c9143688b7a2c567784a131..faff5793459e8ea1c56a79422ce26485e0925b2c 100644 (file)
--- a/src/memcached.c
+++ b/src/memcached.c
static int memcached_connect_unix (memcached_t *st)
{
- struct sockaddr_un serv_addr;
+ struct sockaddr_un serv_addr = { 0 };
int fd;
- memset (&serv_addr, 0, sizeof (serv_addr));
serv_addr.sun_family = AF_UNIX;
sstrncpy (serv_addr.sun_path, st->socket,
sizeof (serv_addr.sun_path));
const char *host;
const char *port;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list, *ai_ptr;
int status;
int fd = -1;
- memset (&ai_hints, 0, sizeof (ai_hints));
- ai_hints.ai_flags = 0;
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
static int memcached_add_read_callback (memcached_t *st)
{
- user_data_t ud;
+ user_data_t ud = { 0 };
char callback_name[3*DATA_MAX_NAME_LEN];
int status;
- memset (&ud, 0, sizeof (ud));
ud.data = st;
ud.free_func = memcached_free;
diff --git a/src/memory.c b/src/memory.c
index 3d8a867a7463c9eab4329d8af34caa1764b8dac5..744af1a8e7999b51706395889e451f6a740b39b0 100644 (file)
--- a/src/memory.c
+++ b/src/memory.c
#elif HAVE_SYSCTL
int mib[] = {CTL_VM, VM_METER};
- struct vmtotal vmtotal;
+ struct vmtotal vmtotal = { 0 };
gauge_t mem_active;
gauge_t mem_inactive;
gauge_t mem_free;
size_t size;
- memset (&vmtotal, 0, sizeof (vmtotal));
size = sizeof (vmtotal);
if (sysctl (mib, 2, &vmtotal, &size, NULL, 0) < 0) {
/* #endif HAVE_LIBSTATGRAB */
#elif HAVE_PERFSTAT
- perfstat_memory_total_t pmemory;
+ perfstat_memory_total_t pmemory = { 0 };
- memset (&pmemory, 0, sizeof (pmemory));
if (perfstat_memory_total(NULL, &pmemory, sizeof(pmemory), 1) < 0)
{
char errbuf[1024];
diff --git a/src/modbus.c b/src/modbus.c
index 11b9bf1be8a8d265ebdd4338ffe96fec5e0c7d19..809194b4c51538d39a3f25180d8be5df77ebc843 100644 (file)
--- a/src/modbus.c
+++ b/src/modbus.c
static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */
mb_data_t *data)
{
- uint16_t values[2];
+ uint16_t values[2] = { 0 };
int values_num;
const data_set_t *ds;
int status = 0;
"is not UINT32.", data->type, DS_TYPE_TO_STRING (ds->ds[0].type));
}
- memset (values, 0, sizeof (values));
if ((data->register_type == REG_TYPE_INT32)
|| (data->register_type == REG_TYPE_UINT32)
|| (data->register_type == REG_TYPE_FLOAT))
static int mb_config_add_data (oconfig_item_t *ci) /* {{{ */
{
- mb_data_t data;
+ mb_data_t data = { 0 };
int status;
int i;
- memset (&data, 0, sizeof (data));
data.name = NULL;
data.register_type = REG_TYPE_UINT16;
data.next = NULL;
{
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
int status;
if ((host == NULL) || (address == NULL))
return (EINVAL);
- memset (&ai_hints, 0, sizeof (ai_hints));
#if AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
diff --git a/src/mqtt.c b/src/mqtt.c
index 7516db48322b43f1a1512047ef1631805f61494e..b318f2116c3030d0e193a92001d9b58925f07e21 100644 (file)
--- a/src/mqtt.c
+++ b/src/mqtt.c
{
mqtt_client_conf_t *conf;
char cb_name[1024];
- user_data_t user_data;
+ user_data_t user_data = { 0 };
int status;
int i;
}
ssnprintf (cb_name, sizeof (cb_name), "mqtt/%s", conf->name);
- memset (&user_data, 0, sizeof (user_data));
user_data.data = conf;
plugin_register_write (cb_name, mqtt_write, &user_data);
diff --git a/src/multimeter.c b/src/multimeter.c
index 6953750525ce34cd2f4e50de26af4cfa6f6949e3..00e9964b85f82718d104c7d4bce8688c702ba6b2 100644 (file)
--- a/src/multimeter.c
+++ b/src/multimeter.c
if ((fd = open(device, O_RDWR | O_NOCTTY)) != -1)
{
- struct termios tios;
+ struct termios tios = { 0 };
int rts = TIOCM_RTS;
double value;
- memset (&tios, 0, sizeof (tios));
tios.c_cflag = B1200 | CS7 | CSTOPB | CREAD | CLOCAL;
tios.c_iflag = IGNBRK | IGNPAR;
tios.c_oflag = 0;
diff --git a/src/mysql.c b/src/mysql.c
index 8ab775fc60ab89c19bd283ac5fab98df97f24ad8..419a154389b768c0e88d67b892f77ef592f3b8e7 100644 (file)
--- a/src/mysql.c
+++ b/src/mysql.c
/* If all went well, register this database for reading */
if (status == 0)
{
- user_data_t ud;
+ user_data_t ud = { 0 };
char cb_name[DATA_MAX_NAME_LEN];
DEBUG ("mysql plugin: Registering new read callback: %s",
(db->database != NULL) ? db->database : "<default>");
- memset (&ud, 0, sizeof (ud));
ud.data = (void *) db;
ud.free_func = mysql_database_free;
diff --git a/src/netapp.c b/src/netapp.c
index e00c252959654ef025291937788a9e2d7858620d..45395ae04b0daf7c7fc9656a5c09b94388711bf9 100644 (file)
--- a/src/netapp.c
+++ b/src/netapp.c
static int cna_handle_wafl_data (const char *hostname, cfg_wafl_t *cfg_wafl, /* {{{ */
na_elem_t *data, cdtime_t interval)
{
- cfg_wafl_t perf_data;
+ cfg_wafl_t perf_data = { 0 };
const char *plugin_inst;
na_elem_t *instances;
na_elem_t *counter;
na_elem_iter_t counter_iter;
- memset (&perf_data, 0, sizeof (perf_data));
-
perf_data.timestamp = cna_child_get_cdtime (data);
instances = na_elem_child(na_elem_child (data, "instances"), "instance-data");
instance = na_iterator_next(&instance_iter))
{
disk_t *old_data;
- disk_t new_data;
+ disk_t new_data = { 0 };
na_elem_iter_t counter_iterator;
na_elem_t *counter;
- memset (&new_data, 0, sizeof (new_data));
new_data.timestamp = timestamp;
new_data.disk_busy_percent = NAN;
{
const char *name;
- data_volume_perf_t perf_data;
+ data_volume_perf_t perf_data = { 0 };
data_volume_perf_t *v;
na_elem_t *elem_counters;
na_elem_iter_t iter_counters;
na_elem_t *elem_counter;
- memset (&perf_data, 0, sizeof (perf_data));
perf_data.timestamp = timestamp;
name = na_child_get_string (elem_instance, "name");
static int cna_change_volume_status (const char *hostname, /* {{{ */
data_volume_usage_t *v)
{
- notification_t n;
+ notification_t n = { 0 };
- memset (&n, 0, sizeof (n));
n.time = cdtime ();
sstrncpy (n.host, hostname, sizeof (n.host));
sstrncpy (n.plugin, "netapp", sizeof (n.plugin));
static int cna_register_host (host_config_t *host) /* {{{ */
{
char cb_name[256];
- user_data_t ud;
+ user_data_t ud = { 0 };
if (host->vfiler)
ssnprintf (cb_name, sizeof (cb_name), "netapp-%s-%s",
else
ssnprintf (cb_name, sizeof (cb_name), "netapp-%s", host->name);
- memset (&ud, 0, sizeof (ud));
ud.data = host;
ud.free_func = (void (*) (void *)) free_host_config;
static int cna_init (void) /* {{{ */
{
- char err[256];
+ char err[256] = { 0 };
- memset (err, 0, sizeof (err));
if (!na_startup(err, sizeof(err))) {
err[sizeof (err) - 1] = 0;
ERROR("netapp plugin: Error initializing netapp API: %s", err);
diff --git a/src/network.c b/src/network.c
index 4393d08af384808506604c5722775f4efe646eba..5a8a88efe388317cd48288ad97e63412b8b6acef 100644 (file)
--- a/src/network.c
+++ b/src/network.c
size_t buffer_offset;
uint16_t username_len;
part_encryption_aes256_t pea;
- unsigned char hash[sizeof (pea.hash)];
+ unsigned char hash[sizeof (pea.hash)] = { 0 };
gcry_cipher_hd_t cypher;
gcry_error_t err;
assert (buffer_offset == (part_size - payload_len));
/* Check hash sum */
- memset (hash, 0, sizeof (hash));
gcry_md_hash_buffer (GCRY_MD_SHA1, hash,
buffer + buffer_offset, payload_len);
if (memcmp (hash, pea.hash, sizeof (hash)) != 0)
int status;
value_list_t vl = VALUE_LIST_INIT;
- notification_t n;
+ notification_t n = { 0 };
#if HAVE_LIBGCRYPT
int packet_was_signed = (flags & PP_SIGNED);
memset (&vl, '\0', sizeof (vl));
- memset (&n, '\0', sizeof (n));
status = 0;
while ((status == 0) && (0 < buffer_size)
@@ -1779,18 +1777,16 @@ static int network_set_interface (const sockent_t *se, const struct addrinfo *ai
* index is preferred here, because of its similarity
* to the way IPv6 handles this. Unfortunately, it
* appears not to be portable. */
- struct ip_mreqn mreq;
-
- memset (&mreq, 0, sizeof (mreq));
- mreq.imr_multiaddr.s_addr = addr->sin_addr.s_addr;
- mreq.imr_address.s_addr = ntohl (INADDR_ANY);
- mreq.imr_ifindex = se->interface;
+ struct ip_mreqn mreq = {
+ .imr_multiaddr.s_addr = addr->sin_addr.s_addr,
+ .imr_address.s_addr = ntohl (INADDR_ANY),
+ .imr_ifindex = se->interface
+ };
#else
- struct ip_mreq mreq;
-
- memset (&mreq, 0, sizeof (mreq));
- mreq.imr_multiaddr.s_addr = addr->sin_addr.s_addr;
- mreq.imr_interface.s_addr = ntohl (INADDR_ANY);
+ struct ip_mreq mreq = {
+ .imr_multiaddr.s_addr = addr->sin_addr.s_addr,
+ .imr_interface.s_addr = ntohl (INADDR_ANY)
+ };
#endif
if (setsockopt (se->data.client.fd, IPPROTO_IP, IP_MULTICAST_IF,
static c_complain_t complaint = C_COMPLAIN_INIT_STATIC;
struct sockent_client *client;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list = NULL, *ai_ptr;
int status;
_Bool reconnect = 0;
if (client->fd >= 0 && !reconnect) /* already connected and not stale*/
return (0);
- memset (&ai_hints, 0, sizeof (ai_hints));
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
/* Open the file descriptors for a initialized sockent structure. */
static int sockent_server_listen (sockent_t *se) /* {{{ */
{
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list, *ai_ptr;
int status;
DEBUG ("network plugin: sockent_server_listen: node = %s; service = %s;",
node, service);
- memset (&ai_hints, 0, sizeof (ai_hints));
- ai_hints.ai_flags = 0;
#ifdef AI_PASSIVE
ai_hints.ai_flags |= AI_PASSIVE;
#endif
static void network_send_buffer_signed (sockent_t *se, /* {{{ */
const char *in_buffer, size_t in_buffer_size)
{
- part_signature_sha256_t ps;
char buffer[BUFF_SIG_SIZE + in_buffer_size];
size_t buffer_offset;
size_t username_len;
in_buffer, in_buffer_size);
/* Initialize the `ps' structure. */
- memset (&ps, 0, sizeof (ps));
- ps.head.type = htons (TYPE_SIGN_SHA256);
- ps.head.length = htons (PART_SIGNATURE_SHA256_SIZE + username_len);
+ part_signature_sha256_t ps = {
+ .head.type = htons (TYPE_SIGN_SHA256),
+ .head.length = htons (PART_SIGNATURE_SHA256_SIZE + username_len)
+ };
/* Calculate the hash value. */
gcry_md_write (hd, buffer + PART_SIGNATURE_SHA256_SIZE,
static void network_send_buffer_encrypted (sockent_t *se, /* {{{ */
const char *in_buffer, size_t in_buffer_size)
{
- part_encryption_aes256_t pea;
char buffer[BUFF_SIG_SIZE + in_buffer_size];
size_t buffer_size;
size_t buffer_offset;
gcry_cipher_hd_t cypher;
/* Initialize the header fields */
- memset (&pea, 0, sizeof (pea));
- pea.head.type = htons (TYPE_ENCR_AES256);
-
- pea.username = se->data.client.username;
+ part_encryption_aes256_t pea = {
+ .head.type = htons (TYPE_ENCR_AES256),
+ .username = se->data.client.username
+ };
username_len = strlen (pea.username);
if ((PART_ENCRYPTION_AES256_SIZE + username_len) > BUFF_SIG_SIZE)
diff --git a/src/notify_nagios.c b/src/notify_nagios.c
index 1f4182bbf8efee2cdd125a7d9f742d8e6289eda3..c16922232b4deb49250ff03b36f0c760251d7a7e 100644 (file)
--- a/src/notify_nagios.c
+++ b/src/notify_nagios.c
char const *file = NAGIOS_COMMAND_FILE;
int fd;
int status;
- struct flock lock;
+ struct flock lock = { 0 };
if (nagios_command_file != NULL)
file = nagios_command_file;
return status;
}
- memset (&lock, 0, sizeof (lock));
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_END;
- lock.l_start = 0;
- lock.l_len = 0; /* to end of file */
status = fcntl (fd, F_GETLK, &lock);
if (status != 0)
diff --git a/src/ntpd.c b/src/ntpd.c
index f8f4f04974bc2f241554d023e5687a8d458d0d4b..f7b57ba30ce30ecc3c7826f879d2d4bb99629028 100644 (file)
--- a/src/ntpd.c
+++ b/src/ntpd.c
const char *host;
const char *port;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
int status;
if (strlen (port) == 0)
port = NTPD_DEFAULT_PORT;
- memset (&ai_hints, '\0', sizeof (ai_hints));
- ai_hints.ai_flags = 0;
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
struct timeval time_now;
int timeout;
- int pkt_item_num; /* items in this packet */
- int pkt_item_len; /* size of the items in this packet */
+ int pkt_item_num; /* items in this packet */
+ int pkt_item_len; /* size of the items in this packet */
int pkt_sequence;
- char pkt_recvd[MAXSEQ+1]; /* sequence numbers that have been received */
- int pkt_recvd_num; /* number of packets that have been received */
- int pkt_lastseq; /* the last sequence number */
- ssize_t pkt_padding; /* Padding in this packet */
+ char pkt_recvd[MAXSEQ+1] = { 0 }; /* sequence numbers that have been received */
+ int pkt_recvd_num; /* number of packets that have been received */
+ int pkt_lastseq; /* the last sequence number */
+ ssize_t pkt_padding; /* Padding in this packet */
if ((sd = ntpd_connect ()) < 0)
return (-1);
items = NULL;
items_num = 0;
- memset (pkt_recvd, '\0', sizeof (pkt_recvd));
pkt_recvd_num = 0;
pkt_lastseq = -1;
static int ntpd_send_request (int req_code, int req_items, int req_size, char *req_data)
{
int sd;
- struct req_pkt req;
+ struct req_pkt req = { 0 };
size_t req_data_len;
int status;
@@ -724,7 +721,6 @@ static int ntpd_send_request (int req_code, int req_items, int req_size, char *r
if ((sd = ntpd_connect ()) < 0)
return (-1);
- memset (&req, '\0', sizeof (req));
req.rm_vn_mode = RM_VN_MODE(0, 0, 0);
req.auth_seq = AUTH_SEQ (0, 0);
req.implementation = IMPL_XNTPD;
@@ -805,20 +801,17 @@ static uint32_t ntpd_get_refclock_id (struct info_peer_summary const *peer_info)
static int ntpd_get_name_from_address (char *buffer, size_t buffer_size,
struct info_peer_summary const *peer_info, _Bool do_reverse_lookup)
{
- struct sockaddr_storage sa;
+ struct sockaddr_storage sa = { 0 };
socklen_t sa_len;
int flags = 0;
int status;
- memset (&sa, 0, sizeof (sa));
-
if (peer_info->v6_flag)
{
- struct sockaddr_in6 sa6;
+ struct sockaddr_in6 sa6 = { 0 };
assert (sizeof (sa) >= sizeof (sa6));
- memset (&sa6, 0, sizeof (sa6));
sa6.sin6_family = AF_INET6;
sa6.sin6_port = htons (123);
memcpy (&sa6.sin6_addr, &peer_info->srcadr6,
}
else
{
- struct sockaddr_in sa4;
+ struct sockaddr_in sa4 = { 0 };
assert (sizeof (sa) >= sizeof (sa4));
- memset (&sa4, 0, sizeof (sa4));
sa4.sin_family = AF_INET;
sa4.sin_port = htons (123);
memcpy (&sa4.sin_addr, &peer_info->srcadr,
diff --git a/src/numa.c b/src/numa.c
index a87a17e9df7c7c0780aa730a280b30c984a94995..4bcc2468826fe5c0313b95e732fb6552f23264f1 100644 (file)
--- a/src/numa.c
+++ b/src/numa.c
while (42)
{
char path[PATH_MAX];
- struct stat statbuf;
+ struct stat statbuf = { 0 };
int status;
ssnprintf (path, sizeof (path), NUMA_ROOT_DIR "/node%i", max_node + 1);
- memset (&statbuf, 0, sizeof (statbuf));
status = stat (path, &statbuf);
if (status == 0)
diff --git a/src/olsrd.c b/src/olsrd.c
index 6d22d98ad4d4bb9920ef606004864fa4d777f16f..2b7e767e7702151762880f744823e0e9c4ea3c81 100644 (file)
--- a/src/olsrd.c
+++ b/src/olsrd.c
@@ -149,14 +149,12 @@ static size_t strtabsplit (char *string, char **fields, size_t size) /* {{{ */
static FILE *olsrd_connect (void) /* {{{ */
{
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list, *ai_ptr;
int ai_return;
FILE *fh;
- memset (&ai_hints, 0, sizeof (ai_hints));
- ai_hints.ai_flags = 0;
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
if (config_want_topology == OLSRD_WANT_DETAIL)
{
- char type_instance[DATA_MAX_NAME_LEN];
+ char type_instance[DATA_MAX_NAME_LEN] = { 0 };
- memset (type_instance, 0, sizeof (type_instance));
ssnprintf (type_instance, sizeof (type_instance), "%s-%s-lq",
fields[0], fields[1]);
DEBUG ("olsrd plugin: type_instance = %s; lq = %g;", type_instance, lq);
}
else
{
- char type_instance[DATA_MAX_NAME_LEN];
+ char type_instance[DATA_MAX_NAME_LEN] = { 0 };
- memset (type_instance, 0, sizeof (type_instance));
ssnprintf (type_instance, sizeof (type_instance), "%s-%s-nlq",
fields[0], fields[1]);
DEBUG ("olsrd plugin: type_instance = %s; nlq = %g;", type_instance, nlq);
diff --git a/src/openldap.c b/src/openldap.c
index 151d25d77120f8fe0e747da31b455fa075c436d1..3dac057eb4bd9bb64768ae36cff670191c1b1b43 100644 (file)
--- a/src/openldap.c
+++ b/src/openldap.c
}
else
{
- user_data_t ud;
- char callback_name[3*DATA_MAX_NAME_LEN];
+ user_data_t ud = { 0 };
+ char callback_name[3*DATA_MAX_NAME_LEN] = { 0 };
databases = temp;
databases[databases_num] = st;
databases_num++;
- memset (&ud, 0, sizeof (ud));
ud.data = st;
- memset (callback_name, 0, sizeof (callback_name));
ssnprintf (callback_name, sizeof (callback_name),
"openldap/%s/%s",
(st->host != NULL) ? st->host : hostname_g,
diff --git a/src/perl.c b/src/perl.c
index 7d78630eb76de69e92c28b84ece8be95c57bf958..fe9f97b5f6dc8f2cbff2430dd57fa5b8d9dba7a2 100644 (file)
--- a/src/perl.c
+++ b/src/perl.c
*/
static int pplugin_dispatch_notification (pTHX_ HV *notif)
{
- notification_t n;
+ notification_t n = { 0 };
int ret;
if (NULL == notif)
return -1;
- memset (&n, 0, sizeof (n));
-
if (0 != hv2notification (aTHX_ notif, &n))
return -1;
diff --git a/src/pf.c b/src/pf.c
index 225d536ebeddcf3f0b969ae251fb2ba8aacb681c..42679febc9d73b895b780c501c1acb8f3b97d3c8 100644 (file)
--- a/src/pf.c
+++ b/src/pf.c
static int pf_read (void)
{
- struct pf_status state;
+ struct pf_status state = { 0 };
int fd;
int status;
int i;
return (-1);
}
- memset (&state, 0, sizeof (state));
status = ioctl (fd, DIOCGETSTATUS, &state);
if (status != 0)
{
diff --git a/src/pinba.c b/src/pinba.c
index cfc07774f5560e0fd12516e7642412e52d2fe9cc..833fa1b8cdd4cc997363af376652748fe2dc49d1 100644 (file)
--- a/src/pinba.c
+++ b/src/pinba.c
pinba_socket_t *s;
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
int status;
- memset (&ai_hints, 0, sizeof (ai_hints));
ai_hints.ai_flags = AI_PASSIVE;
ai_hints.ai_family = AF_UNSPEC;
ai_hints.ai_socktype = SOCK_DGRAM;
diff --git a/src/postgresql.c b/src/postgresql.c
index 41ce95cdf08b15f34cb7067d05a477c69c6a37da..65766a9f107a2ab3ec67e5ee9571bd88f1ed4df4 100644 (file)
--- a/src/postgresql.c
+++ b/src/postgresql.c
c_psql_database_t *db;
char cb_name[DATA_MAX_NAME_LEN];
- user_data_t ud;
+ user_data_t ud = { 0 };
static _Bool have_flush = 0;
return 1;
}
- memset (&ud, 0, sizeof (ud));
-
db = c_psql_database_new (ci->values[0].value.string);
if (db == NULL)
return -1;
diff --git a/src/powerdns.c b/src/powerdns.c
index f72bd40ffcd52c8099362fa4397053d1fdb7239d..55f13fef09fbac6f0a30297bcb4d90f72da9c9c2 100644 (file)
--- a/src/powerdns.c
+++ b/src/powerdns.c
char *buffer = NULL;
size_t buffer_size = 0;
- struct sockaddr_un sa_unix;
+ struct sockaddr_un sa_unix = { 0 };
struct timeval stv_timeout;
cdtime_t cdt_timeout;
return (-1);
}
- memset (&sa_unix, 0, sizeof (sa_unix));
sa_unix.sun_family = AF_UNIX;
sstrncpy (sa_unix.sun_path,
(local_sockpath != NULL) ? local_sockpath : PDNS_LOCAL_SOCKPATH,
diff --git a/src/python.c b/src/python.c
index 61d464d82957ece7ac4300389dd077344404770e..3a282918c6eafe6ae32b3de7109fff388edf1075 100644 (file)
--- a/src/python.c
+++ b/src/python.c
@@ -623,7 +623,7 @@ static PyObject *cpy_register_generic_userdata(void *reg, void *handler, PyObjec
char buf[512];
reg_function_t *register_function = (reg_function_t *) reg;
cpy_callback_t *c = NULL;
- user_data_t user_data;
+ user_data_t user_data = { 0 };
char *name = NULL;
PyObject *callback = NULL, *data = NULL;
static char *kwlist[] = {"callback", "data", "name", NULL};
@@ -649,7 +649,6 @@ static PyObject *cpy_register_generic_userdata(void *reg, void *handler, PyObjec
c->data = data;
c->next = NULL;
- memset (&user_data, 0, sizeof (user_data));
user_data.free_func = cpy_destroy_user_data;
user_data.data = c;
@@ -660,7 +659,7 @@ static PyObject *cpy_register_generic_userdata(void *reg, void *handler, PyObjec
static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwds) {
char buf[512];
cpy_callback_t *c = NULL;
- user_data_t user_data;
+ user_data_t user_data = { 0 };
double interval = 0;
char *name = NULL;
PyObject *callback = NULL, *data = NULL;
@@ -687,7 +686,6 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwd
c->data = data;
c->next = NULL;
- memset (&user_data, 0, sizeof (user_data));
user_data.free_func = cpy_destroy_user_data;
user_data.data = c;
static void *cpy_interactive(void *data) {
sigset_t sigset;
- struct sigaction sig_int_action, old;
+ struct sigaction old;
/* Signal handler in a plugin? Bad stuff, but the best way to
* handle it I guess. In an interactive session people will
* still interrupt syscalls like sleep and pause.
* It does not raise a KeyboardInterrupt exception because so
* far nobody managed to figure out how to do that. */
- memset (&sig_int_action, '\0', sizeof (sig_int_action));
- sig_int_action.sa_handler = cpy_int_handler;
+ struct sigaction sig_int_action = {
+ .sa_handler = cpy_int_handler
+ };
sigaction (SIGINT, &sig_int_action, &old);
sigemptyset(&sigset);
diff --git a/src/redis.c b/src/redis.c
index 2d0bd958db9588843155d10dab7bfcf10ddc12e4..47d0d707f5c8ca52b972c42e2e1bf416cd89e2e0 100644 (file)
--- a/src/redis.c
+++ b/src/redis.c
static int redis_config_node (oconfig_item_t *ci) /* {{{ */
{
- redis_node_t rn;
redis_query_t *rq;
int i;
int status;
int timeout;
- memset (&rn, 0, sizeof (rn));
+ redis_node_t rn = {
+ .port = REDIS_DEF_PORT,
+ .timeout.tv_usec = REDIS_DEF_TIMEOUT
+ };
+
sstrncpy (rn.host, REDIS_DEF_HOST, sizeof (rn.host));
- rn.port = REDIS_DEF_PORT;
- rn.timeout.tv_usec = REDIS_DEF_TIMEOUT;
- rn.queries = NULL;
status = cf_util_get_string_buffer (ci, rn.name, sizeof (rn.name));
if (status != 0)
diff --git a/src/snmp.c b/src/snmp.c
index 6a5bb8b964802af92ffad9d600e1255e2ed3a4d8..084925586d1f7eb37936e5ad1db5cddf7865462c 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
/* Registration stuff. */
char cb_name[DATA_MAX_NAME_LEN];
- user_data_t cb_data;
+ user_data_t cb_data = { 0 };
hd = calloc (1, sizeof (*hd));
if (hd == NULL)
ssnprintf (cb_name, sizeof (cb_name), "snmp-%s", hd->name);
- memset (&cb_data, 0, sizeof (cb_data));
cb_data.data = hd;
cb_data.free_func = csnmp_host_definition_destroy;
}
else
{
- char oid_buffer[1024];
+ char oid_buffer[1024] = { 0 };
- memset (oid_buffer, 0, sizeof (oid_buffer));
snprint_objid (oid_buffer, sizeof (oid_buffer) - 1,
vl->name, vl->name_length);
@@ -1276,7 +1274,6 @@ static int csnmp_dispatch_table (host_definition_t *host, data_definition_t *dat
vl.interval = host->interval;
have_more = 1;
- memset (¤t_suffix, 0, sizeof (current_suffix));
while (have_more)
{
_Bool suffix_skipped = 0;
diff --git a/src/statsd.c b/src/statsd.c
index a0c6e4f3e935117fd9f4c428a64072e7f007bdff..1eb8cb94c59df032f1615909a1341ec63cab432c 100644 (file)
--- a/src/statsd.c
+++ b/src/statsd.c
struct pollfd *fds = NULL;
size_t fds_num = 0;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list = NULL;
struct addrinfo *ai_ptr;
int status;
char const *service = (conf_service != NULL)
? conf_service : STATSD_DEFAULT_SERVICE;
- memset (&ai_hints, 0, sizeof (ai_hints));
ai_hints.ai_flags = AI_PASSIVE;
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
diff --git a/src/swap.c b/src/swap.c
index d714b5fcdb8d7e558eb02d1c7a787b506bc07230..645dc586023523ae7af55722da4f20e3ca416442 100644 (file)
--- a/src/swap.c
+++ b/src/swap.c
#elif HAVE_PERFSTAT
static int swap_read (void) /* {{{ */
{
- perfstat_memory_total_t pmemory;
+ perfstat_memory_total_t pmemory = { 0 };
int status;
gauge_t total;
gauge_t free;
gauge_t reserved;
- memset (&pmemory, 0, sizeof (pmemory));
status = perfstat_memory_total (NULL, &pmemory, sizeof(perfstat_memory_total_t), 1);
if (status < 0)
{
diff --git a/src/tail.c b/src/tail.c
index 5402f6664857e26c671be1f5650b37a3c6d718ac..b9e9206890ff965f52521ab77ae722c64e9cfedc 100644 (file)
--- a/src/tail.c
+++ b/src/tail.c
static int ctail_config_add_match (cu_tail_match_t *tm,
const char *plugin_instance, oconfig_item_t *ci, cdtime_t interval)
{
- ctail_config_match_t cm;
+ ctail_config_match_t cm = { 0 };
int status;
int i;
- memset (&cm, '\0', sizeof (cm));
-
if (ci->values_num != 0)
{
WARNING ("tail plugin: Ignoring arguments for the `Match' block.");
static int ctail_init (void)
{
char str[255];
- user_data_t ud;
+ user_data_t ud = { 0 };
size_t i;
if (tail_match_list_num == 0)
return (-1);
}
- memset(&ud, '\0', sizeof(ud));
-
for (i = 0; i < tail_match_list_num; i++)
{
ud.data = (void *)tail_match_list[i];
diff --git a/src/tail_csv.c b/src/tail_csv.c
index a768ef81da850b721a4297709deb4e30500c6358..70710216f320c99f5e971e05e3ac05d62ebd921e 100644 (file)
--- a/src/tail_csv.c
+++ b/src/tail_csv.c
/* Registration variables */
char cb_name[DATA_MAX_NAME_LEN];
- user_data_t cb_data;
+ user_data_t cb_data = { 0 };
id = calloc(1, sizeof(*id));
if (id == NULL)
}
ssnprintf (cb_name, sizeof (cb_name), "tail_csv/%s", id->path);
- memset(&cb_data, 0, sizeof(cb_data));
cb_data.data = id;
cb_data.free_func = tcsv_instance_definition_destroy;
status = plugin_register_complex_read(NULL, cb_name, tcsv_read, id->interval, &cb_data);
index 55b72ac1acf330f15ea8899aa8181ca134a64bd3..63e4f3154f15b97356a012560c2242cb06bb7db5 100644 (file)
notification_meta_t __attribute__((unused)) **meta, void **user_data)
{
tn_data_t *data;
- notification_t n;
+ notification_t n = { 0 };
char temp[NOTIF_MAX_MSG_LEN];
gauge_t *rates;
}
/* Initialize the structure. */
- memset (&n, 0, sizeof (n));
n.severity = data->severity;
n.time = cdtime ();
sstrncpy (n.message, data->message, sizeof (n.message));
void module_register (void)
{
- target_proc_t tproc;
+ target_proc_t tproc = { 0 };
- memset (&tproc, 0, sizeof (tproc));
tproc.create = tn_create;
tproc.destroy = tn_destroy;
tproc.invoke = tn_invoke;
diff --git a/src/target_replace.c b/src/target_replace.c
index 545fa3530f960a61c26be2012cbebd8fcc0d4290..8d774c570f849d7beed5e378a7d936c5d6f2a070 100644 (file)
--- a/src/target_replace.c
+++ b/src/target_replace.c
tr_action_t *act;
int status;
char buffer[DATA_MAX_NAME_LEN];
- regmatch_t matches[8];
+ regmatch_t matches[8] = { [0] = { 0 } };
if (act_head == NULL)
return (-EINVAL);
sstrncpy (buffer, buffer_in, sizeof (buffer));
- memset (matches, 0, sizeof (matches));
DEBUG ("target_replace plugin: tr_action_invoke: <- buffer = %s;", buffer);
void module_register (void)
{
- target_proc_t tproc;
+ target_proc_t tproc = { 0 };
- memset (&tproc, 0, sizeof (tproc));
tproc.create = tr_create;
tproc.destroy = tr_destroy;
tproc.invoke = tr_invoke;
diff --git a/src/target_scale.c b/src/target_scale.c
index 74652ff81dbeeb6452f0fce8c2d01768e10d3836..579d01a03c3908b0e5b8e85e5316ce1815a6f8c2 100644 (file)
--- a/src/target_scale.c
+++ b/src/target_scale.c
void module_register (void)
{
- target_proc_t tproc;
+ target_proc_t tproc = { 0 };
- memset (&tproc, 0, sizeof (tproc));
tproc.create = ts_create;
tproc.destroy = ts_destroy;
tproc.invoke = ts_invoke;
diff --git a/src/target_set.c b/src/target_set.c
index 6115639b5bcd73679b41f4a5623b0f38b43cbd69..2060dcde6b050e1616acc83481ce48ea5a957098 100644 (file)
--- a/src/target_set.c
+++ b/src/target_set.c
void module_register (void)
{
- target_proc_t tproc;
+ target_proc_t tproc = { 0 };
- memset (&tproc, 0, sizeof (tproc));
tproc.create = ts_create;
tproc.destroy = ts_destroy;
tproc.invoke = ts_invoke;
diff --git a/src/target_v5upgrade.c b/src/target_v5upgrade.c
index d85a181fb933d9fbdda91c8c366539834fbf8586..6d661711b3cfab1632825519ade9f75f2f62a34e 100644 (file)
--- a/src/target_v5upgrade.c
+++ b/src/target_v5upgrade.c
void module_register (void)
{
- target_proc_t tproc;
+ target_proc_t tproc = { 0 };
- memset (&tproc, 0, sizeof (tproc));
tproc.create = v5_create;
tproc.destroy = v5_destroy;
tproc.invoke = v5_invoke;
diff --git a/src/tcpconns.c b/src/tcpconns.c
index 6bc3384210ce5a614b4f39b7fb3d05b965165865..da916950e301c5a705fdfe5c18c80b48b336d4a3 100644 (file)
--- a/src/tcpconns.c
+++ b/src/tcpconns.c
{
#if HAVE_STRUCT_LINUX_INET_DIAG_REQ
int fd;
- struct sockaddr_nl nladdr;
- struct nlreq req;
- struct msghdr msg;
- struct iovec iov;
struct inet_diag_msg *r;
char buf[8192];
return (-1);
}
- memset(&nladdr, 0, sizeof(nladdr));
- nladdr.nl_family = AF_NETLINK;
-
- memset(&req, 0, sizeof(req));
- req.nlh.nlmsg_len = sizeof(req);
- req.nlh.nlmsg_type = TCPDIAG_GETSOCK;
- /* NLM_F_ROOT: return the complete table instead of a single entry.
- * NLM_F_MATCH: return all entries matching criteria (not implemented)
- * NLM_F_REQUEST: must be set on all request messages */
- req.nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
- req.nlh.nlmsg_pid = 0;
- /* The sequence_number is used to track our messages. Since netlink is not
- * reliable, we don't want to end up with a corrupt or incomplete old
- * message in case the system is/was out of memory. */
- req.nlh.nlmsg_seq = ++sequence_number;
- req.r.idiag_family = AF_INET;
- req.r.idiag_states = 0xfff;
- req.r.idiag_ext = 0;
-
- memset(&iov, 0, sizeof(iov));
- iov.iov_base = &req;
- iov.iov_len = sizeof(req);
-
- memset(&msg, 0, sizeof(msg));
- msg.msg_name = (void*)&nladdr;
- msg.msg_namelen = sizeof(nladdr);
- msg.msg_iov = &iov;
- msg.msg_iovlen = 1;
+ struct sockaddr_nl nladdr = {
+ .nl_family = AF_NETLINK
+ };
+
+ struct nlreq req = {
+ .nlh.nlmsg_len = sizeof(req),
+ .nlh.nlmsg_type = TCPDIAG_GETSOCK,
+ /* NLM_F_ROOT: return the complete table instead of a single entry.
+ * NLM_F_MATCH: return all entries matching criteria (not implemented)
+ * NLM_F_REQUEST: must be set on all request messages */
+ .nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST,
+ .nlh.nlmsg_pid = 0,
+ /* The sequence_number is used to track our messages. Since netlink is not
+ * reliable, we don't want to end up with a corrupt or incomplete old
+ * message in case the system is/was out of memory. */
+ .nlh.nlmsg_seq = ++sequence_number,
+ .r.idiag_family = AF_INET,
+ .r.idiag_states = 0xfff,
+ .r.idiag_ext = 0
+ };
+
+ struct iovec iov = {
+ .iov_base = &req,
+ .iov_len = sizeof(req)
+ };
+
+ struct msghdr msg = {
+ .msg_name = (void*)&nladdr,
+ .msg_namelen = sizeof(nladdr),
+ .msg_iov = &iov,
+ .msg_iovlen = 1
+ };
if (sendmsg (fd, &msg, 0) < 0)
{
diff --git a/src/teamspeak2.c b/src/teamspeak2.c
index 638109caac37b3af2f95c215a947c2bc0bec2c7f..cf093c5feec35debf969b27d4c1fac8b432b20ba 100644 (file)
--- a/src/teamspeak2.c
+++ b/src/teamspeak2.c
* Returns connected file objects or establishes the connection
* if it's not already present
*/
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_head;
struct addrinfo *ai_ptr;
int sd = -1;
}
/* Get all addrs for this hostname */
- memset (&ai_hints, 0, sizeof (ai_hints));
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
gauge_t packet_loss = NAN;
int valid = 0;
- char plugin_instance[DATA_MAX_NAME_LEN];
+ char plugin_instance[DATA_MAX_NAME_LEN] = { 0 };
FILE *read_fh;
FILE *write_fh;
if (vserver == NULL)
{
/* Request global information */
- memset (plugin_instance, 0, sizeof (plugin_instance));
-
status = tss2_send_request (write_fh, "gi\r\n");
}
else
diff --git a/src/ted.c b/src/ted.c
index 186cf2b4bb1399b32fcfcbf3f585fe3b6539a715..282212b114f0c1832a4401663825aebf0678715c 100644 (file)
--- a/src/ted.c
+++ b/src/ted.c
int package_buffer_pos;
fd_set input;
- struct timeval timeout;
+
+ /* Initialize timeout structure, set to 2 seconds */
+ struct timeval timeout = {
+ .tv_sec = 2
+ };
int end_flag;
int escape_flag;
FD_ZERO (&input);
FD_SET (fd, &input);
- /* Initialize timeout structure, set to 2 seconds */
- memset (&timeout, 0, sizeof (timeout));
- timeout.tv_sec = 2;
- timeout.tv_usec = 0;
-
/* clear out anything in the buffer */
tcflush (fd, TCIFLUSH);
diff --git a/src/threshold.c b/src/threshold.c
index 77ba3f324b6e425afb4233fe0526b1cb86afdf8c..f12b405773609c89cbe37ea4e8061d93d714a706 100644 (file)
--- a/src/threshold.c
+++ b/src/threshold.c
int status = 0;
int old_size = c_avl_size (threshold_tree);
- threshold_t th;
-
if (threshold_tree == NULL)
{
threshold_tree = c_avl_create ((int (*) (const void *, const void *)) strcmp);
}
}
- memset (&th, '\0', sizeof (th));
- th.warning_min = NAN;
- th.warning_max = NAN;
- th.failure_min = NAN;
- th.failure_max = NAN;
-
- th.hits = 0;
- th.hysteresis = 0;
- th.flags = UT_FLAG_INTERESTING; /* interesting by default */
+ threshold_t th = {
+ .warning_min = NAN,
+ .warning_max = NAN,
+ .failure_min = NAN,
+ .failure_max = NAN,
+ .flags = UT_FLAG_INTERESTING /* interesting by default */
+ };
for (i = 0; i < ci->children_num; i++)
{
diff --git a/src/unixsock.c b/src/unixsock.c
index d4bf004731abf3142253a9833a742004f48420a0..5454fd8c273eb948b9d119e4d4dab73414c0636f 100644 (file)
--- a/src/unixsock.c
+++ b/src/unixsock.c
*/
static int us_open_socket (void)
{
- struct sockaddr_un sa;
+ struct sockaddr_un sa = { 0 };
int status;
sock_fd = socket (PF_UNIX, SOCK_STREAM, 0);
return (-1);
}
- memset (&sa, '\0', sizeof (sa));
sa.sun_family = AF_UNIX;
sstrncpy (sa.sun_path, (sock_file != NULL) ? sock_file : US_DEFAULT_PATH,
sizeof (sa.sun_path));
diff --git a/src/uptime.c b/src/uptime.c
index 345128da62f6750d30655d74a3f35a841ec6a110..4116b810fc176c2a73ec7aa6bf807cc8971ab8d9 100644 (file)
--- a/src/uptime.c
+++ b/src/uptime.c
/* #endif HAVE_LIBKSTAT */
# elif HAVE_SYS_SYSCTL_H
- struct timeval boottv;
+ struct timeval boottv = { 0 };
size_t boottv_len;
int status;
- int mib[2];
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_BOOTTIME;
+ int mib[] = { CTL_KERN, KERN_BOOTTIME };
boottv_len = sizeof (boottv);
- memset (&boottv, 0, boottv_len);
status = sysctl (mib, STATIC_ARRAY_SIZE (mib), &boottv, &boottv_len,
/* new_value = */ NULL, /* new_length = */ 0);
index 80babe3ebdc4dc36d63656c5c346ea67e297cc97..7e4a9db19f4961392ed5bfb19f0680860c10e0b3 100644 (file)
char *type;
char *type_instance;
- value_list_t vl;
threshold_t threshold;
int status;
return (-1);
}
- memset (&vl, 0, sizeof (vl));
+ value_list_t vl = {
+ .values = NULL
+ };
sstrncpy (vl.host, host, sizeof (vl.host));
sstrncpy (vl.plugin, plugin, sizeof (vl.plugin));
if (plugin_instance != NULL)
sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
sfree (identifier_copy);
- memset (&threshold, 0, sizeof (threshold));
status = ut_search_threshold (&vl, &threshold);
if (status == ENOENT)
{
index 145cd107c771b7330bcd20fa18e737a810e76000..956ed745cffdd102a824bc8bc363e8bc102d74e7 100644 (file)
--- a/src/utils_cmd_putnotif.c
+++ b/src/utils_cmd_putnotif.c
@@ -119,7 +119,7 @@ static int set_option (notification_t *n, const char *option, const char *value)
int handle_putnotif (FILE *fh, char *buffer)
{
char *command;
- notification_t n;
+ notification_t n = { 0 };
int status;
if ((fh == NULL) || (buffer == NULL))
return (-1);
}
- memset (&n, '\0', sizeof (n));
-
status = 0;
while (*buffer != 0)
{
diff --git a/src/utils_fbhash.c b/src/utils_fbhash.c
index d1a580cd632420d0ab25e9a6186d5210e63d6b55..d980f58605c1750d3451d7647b3f50fdbd5f03ee 100644 (file)
--- a/src/utils_fbhash.c
+++ b/src/utils_fbhash.c
{
FILE *fh;
char buffer[4096];
- struct flock fl;
+ struct flock fl = { 0 };
c_avl_tree_t *tree;
int status;
if (fh == NULL)
return (-1);
- memset (&fl, 0, sizeof (fl));
fl.l_type = F_RDLCK;
fl.l_whence = SEEK_SET;
- fl.l_start = 0;
- fl.l_len = 0; /* == entire file */
/* TODO: Lock file? -> fcntl */
status = fcntl (fileno (fh), F_SETLK, &fl);
static int fbh_check_file (fbhash_t *h) /* {{{ */
{
- struct stat statbuf;
+ struct stat statbuf = { 0 };
int status;
- memset (&statbuf, 0, sizeof (statbuf));
-
status = stat (h->filename, &statbuf);
if (status != 0)
return (-1);
index 2d541eea9a29e021f15c88d3e2774afdda2b3213..668a8d0ca4975c3fc669ade6834ad0f5cf97445c 100644 (file)
identifier_t ident;
void *user_class;
- memset (&ident, 0, sizeof (ident));
strncpy (ident.host, host, sizeof (ident.host));
strncpy (ident.plugin, plugin, sizeof (ident.plugin));
strncpy (ident.plugin_instance, plugin_instance, sizeof (ident.plugin_instance));
diff --git a/src/write_graphite.c b/src/write_graphite.c
index 64794bec964a7823bf5f9028516a1848573e846a..25c7a637759daa0a78ec66f5f080ffd99ef22893 100644 (file)
--- a/src/write_graphite.c
+++ b/src/write_graphite.c
static int wg_callback_init (struct wg_callback *cb)
{
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
cdtime_t now;
return (EAGAIN);
cb->last_connect_time = now;
- memset (&ai_hints, 0, sizeof (ai_hints));
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
static int wg_write_messages (const data_set_t *ds, const value_list_t *vl,
struct wg_callback *cb)
{
- char buffer[WG_SEND_BUF_SIZE];
+ char buffer[WG_SEND_BUF_SIZE] = { 0 };
int status;
if (0 != strcmp (ds->type, vl->type))
return -1;
}
- memset (buffer, 0, sizeof (buffer));
status = format_graphite (buffer, sizeof (buffer), ds, vl,
cb->prefix, cb->postfix, cb->escape_char, cb->format_flags);
if (status != 0) /* error message has been printed already. */
static int config_set_char (char *dest,
oconfig_item_t *ci)
{
- char buffer[4];
+ char buffer[4] = { 0 };
int status;
- memset (buffer, 0, sizeof (buffer));
-
status = cf_util_get_string_buffer (ci, buffer, sizeof (buffer));
if (status != 0)
return (status);
static int wg_config_node (oconfig_item_t *ci)
{
struct wg_callback *cb;
- user_data_t user_data;
+ user_data_t user_data = { 0 };
char callback_name[DATA_MAX_NAME_LEN];
int i;
int status = 0;
ssnprintf (callback_name, sizeof (callback_name), "write_graphite/%s",
cb->name);
- memset (&user_data, 0, sizeof (user_data));
user_data.data = cb;
user_data.free_func = wg_callback_free;
plugin_register_write (callback_name, wg_write, &user_data);
diff --git a/src/write_http.c b/src/write_http.c
index 2d8e5535c2db3c8261484bd2d41bdfbc57e2547f..3c2f72489fe1d05a3c6b1fd5b923cb24fbb40e1f 100644 (file)
--- a/src/write_http.c
+++ b/src/write_http.c
{
wh_callback_t *cb;
int buffer_size = 0;
- user_data_t user_data;
+ user_data_t user_data = { 0 };
char callback_name[DATA_MAX_NAME_LEN];
int status = 0;
int i;
DEBUG ("write_http: Registering write callback '%s' with URL '%s'",
callback_name, cb->location);
- memset (&user_data, 0, sizeof (user_data));
user_data.data = cb;
- user_data.free_func = NULL;
plugin_register_flush (callback_name, wh_flush, &user_data);
user_data.free_func = wh_callback_free;
diff --git a/src/write_log.c b/src/write_log.c
index db09849fefc75aa2691a8c663be40f885b63a0fb..25ff55e2c509638481b96fd8c7035d23c3d73658 100644 (file)
--- a/src/write_log.c
+++ b/src/write_log.c
static int wl_write_messages (const data_set_t *ds, const value_list_t *vl)
{
- char buffer[WL_BUF_SIZE];
+ char buffer[WL_BUF_SIZE] = { 0 };
int status;
if (0 != strcmp (ds->type, vl->type))
return -1;
}
- memset (buffer, 0, sizeof (buffer));
status = format_graphite (buffer, sizeof (buffer), ds, vl,
NULL, NULL, '_', 0);
if (status != 0) /* error message has been printed already. */
diff --git a/src/write_redis.c b/src/write_redis.c
index 5c299a489dfa6eef0f914992f595df1cf55c48ce..4ec75d59b269ad6b4a671c596b6ad3123ce42fb5 100644 (file)
--- a/src/write_redis.c
+++ b/src/write_redis.c
wr_node_t *node = ud->data;
char ident[512];
char key[512];
- char value[512];
+ char value[512] = { 0 };
char time[24];
size_t value_size;
char *value_ptr;
ident);
ssnprintf (time, sizeof (time), "%.9f", CDTIME_T_TO_DOUBLE(vl->time));
- memset (value, 0, sizeof (value));
value_size = sizeof (value);
value_ptr = &value[0];
status = format_values (value_ptr, value_size, ds, vl, node->store_rates);
diff --git a/src/write_tsdb.c b/src/write_tsdb.c
index 2bd27072398541c124016f1c6e97fc8c26936726..a044b6819a64a24ef51cfed8c3235422ef60dcf6 100644 (file)
--- a/src/write_tsdb.c
+++ b/src/write_tsdb.c
static int wt_callback_init(struct wt_callback *cb)
{
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
int status;
if (cb->sock_fd > 0)
return 0;
- memset(&ai_hints, 0, sizeof(ai_hints));
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
#endif
static int wt_config_tsd(oconfig_item_t *ci)
{
struct wt_callback *cb;
- user_data_t user_data;
+ user_data_t user_data = { 0 };
char callback_name[DATA_MAX_NAME_LEN];
int i;
cb->node != NULL ? cb->node : WT_DEFAULT_NODE,
cb->service != NULL ? cb->service : WT_DEFAULT_SERVICE);
- memset(&user_data, 0, sizeof(user_data));
user_data.data = cb;
user_data.free_func = wt_callback_free;
plugin_register_write(callback_name, wt_write, &user_data);
diff --git a/src/zookeeper.c b/src/zookeeper.c
index 860e93d768e927dffa81a18a614f9cabda82bb42..a236c8ae66404bd5173c0be7e2537246e34511f4 100644 (file)
--- a/src/zookeeper.c
+++ b/src/zookeeper.c
{
int sk = -1;
int status;
- struct addrinfo ai_hints;
+ struct addrinfo ai_hints = { 0 };
struct addrinfo *ai;
struct addrinfo *ai_list;
const char *host;
const char *port;
- memset (&ai_hints, '\0', sizeof (ai_hints));
ai_hints.ai_family = AF_UNSPEC;
ai_hints.ai_socktype = SOCK_STREAM;