treewide: replace memset to 0 with initializers
[collectd.git] / src / ceph.c
index 04a3974..c34d209 100644 (file)
@@ -267,7 +267,7 @@ ceph_cb_number(void *ctx, const char *number_val, yajl_len_t number_len)
 {
     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;
@@ -275,7 +275,6 @@ ceph_cb_number(void *ctx, const char *number_val, yajl_len_t number_len)
     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)
@@ -592,8 +591,7 @@ static int ceph_daemon_add_ds_entry(struct ceph_daemon *d, const char *name,
         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)
     {
@@ -685,9 +683,8 @@ static int cc_handle_bool(struct oconfig_item_s *item, int *dest)
 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))
     {
@@ -982,8 +979,7 @@ static int node_handler_fetch_data(void *arg, const char *val, const char *key)
     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)
     {
@@ -1101,7 +1097,6 @@ static int cconn_connect(struct cconn *io)
             "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);