diff options
31 files changed, 96 insertions, 761 deletions
diff --git a/cli/src/cli-cmd-system.c b/cli/src/cli-cmd-system.c index 3b1d967b650..c41594bfa59 100644 --- a/cli/src/cli-cmd-system.c +++ b/cli/src/cli-cmd-system.c @@ -469,7 +469,6 @@ cli_cmd_sys_exec_cbk (struct cli_state *state, struct cli_cmd_word *word, tmp = strtok_r (NULL, " ", &saveptr); if (tmp) { in_cmd_args_count++; - memset (cmd_arg_name, '\0', sizeof(cmd_arg_name)); snprintf (cmd_arg_name, sizeof(cmd_arg_name), "cmd_arg_%d", in_cmd_args_count); ret = dict_set_str (dict, cmd_arg_name, tmp); @@ -491,7 +490,6 @@ cli_cmd_sys_exec_cbk (struct cli_state *state, struct cli_cmd_word *word, for (i=1; i <= cmd_args_count; i++) { in_cmd_args_count++; - memset (cmd_arg_name, '\0', sizeof(cmd_arg_name)); snprintf (cmd_arg_name, sizeof(cmd_arg_name), "cmd_arg_%d", in_cmd_args_count); ret = dict_set_str (dict, cmd_arg_name, diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 099ba403ee8..70a7a1a19d7 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -2633,7 +2633,6 @@ cli_get_detail_status (dict_t *dict, int i, cli_volume_status_t *status) char key[1024] = {0}; int ret = 0; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.free", i); ret = dict_get_uint64 (dict, key, &free); @@ -2641,7 +2640,6 @@ cli_get_detail_status (dict_t *dict, int i, cli_volume_status_t *status) if (!status->free) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.total", i); ret = dict_get_uint64 (dict, key, &total); @@ -2649,13 +2647,11 @@ cli_get_detail_status (dict_t *dict, int i, cli_volume_status_t *status) if (!status->total) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.device", i); ret = dict_get_str (dict, key, &(status->device)); if (ret) status->device = NULL; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.block_size", i); ret = dict_get_uint64 (dict, key, &(status->block_size)); if (ret) { @@ -2663,13 +2659,11 @@ cli_get_detail_status (dict_t *dict, int i, cli_volume_status_t *status) status->block_size = 0; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mnt_options", i); ret = dict_get_str (dict, key, &(status->mount_options)); if (ret) status->mount_options = NULL; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.fs_name", i); ret = dict_get_str (dict, key, &(status->fs_name)); if (ret) { @@ -2677,20 +2671,17 @@ cli_get_detail_status (dict_t *dict, int i, cli_volume_status_t *status) status->fs_name = NULL; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.inode_size", i); ret = dict_get_str (dict, key, &(status->inode_size)); if (ret) status->inode_size = NULL; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.total_inodes", i); ret = dict_get_uint64 (dict, key, &(status->total_inodes)); if (ret) status->total_inodes = 0; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.free_inodes", i); ret = dict_get_uint64 (dict, key, &(status->free_inodes)); if (ret) { diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index b3a35c312b8..9812bbdab18 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -230,7 +230,6 @@ gf_cli_output_peer_hostnames (dict_t *dict, int count, char *prefix) * as friend.hostname */ for (i = 1; i < count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.hostname%d", prefix, i); ret = dict_get_str (dict, key, &hostname); if (ret) @@ -286,13 +285,11 @@ gf_cli_output_peer_status (dict_t *dict, int count) cli_out ("\nHostname: %s\nUuid: %s\nState: %s (%s)", hostname_buf, uuid_buf, state, connected_str); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.hostname_count", i); ret = dict_get_int32 (dict, key, &hostname_count); /* Print other addresses only if there are more than 1. */ if ((ret == 0) && (hostname_count > 1)) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d", i); ret = gf_cli_output_peer_hostnames (dict, hostname_count, @@ -634,12 +631,10 @@ print_brick_details (dict_t *dict, int volcount, int start_index, #endif while (index <= end_index) { - memset (key, 0, sizeof (key)); snprintf (key, 1024, "volume%d.brick%d", volcount, index); ret = dict_get_str (dict, key, &brick); if (ret) goto out; - memset (key, 0, sizeof(key)); snprintf (key, sizeof (key), "volume%d.brick%d.isArbiter", volcount, index); if (dict_get (dict, key)) @@ -728,63 +723,53 @@ gf_cli_print_tier_info (dict_t *dict, int i, int brick_count) GF_ASSERT (dict); - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_brick_count", i); + snprintf (key, sizeof (key), "volume%d.cold_brick_count", i); ret = dict_get_int32 (dict, key, &cold_brick_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_type", i); + snprintf (key, sizeof (key), "volume%d.cold_type", i); ret = dict_get_int32 (dict, key, &cold_type); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_dist_count", i); + snprintf (key, sizeof (key), "volume%d.cold_dist_count", i); ret = dict_get_int32 (dict, key, &cold_dist_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_replica_count", i); + snprintf (key, sizeof (key), "volume%d.cold_replica_count", i); ret = dict_get_int32 (dict, key, &cold_replica_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_arbiter_count", i); + snprintf (key, sizeof (key), "volume%d.cold_arbiter_count", i); ret = dict_get_int32 (dict, key, &cold_arbiter_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_disperse_count", i); + snprintf (key, sizeof (key), "volume%d.cold_disperse_count", i); ret = dict_get_int32 (dict, key, &cold_disperse_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, + snprintf (key, sizeof (key), "volume%d.cold_redundancy_count", i); ret = dict_get_int32 (dict, key, &cold_redundancy_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.hot_brick_count", i); + snprintf (key, sizeof (key), "volume%d.hot_brick_count", i); ret = dict_get_int32 (dict, key, &hot_brick_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.hot_type", i); + snprintf (key, sizeof (key), "volume%d.hot_type", i); ret = dict_get_int32 (dict, key, &hot_type); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.hot_replica_count", i); + snprintf (key, sizeof (key), "volume%d.hot_replica_count", i); ret = dict_get_int32 (dict, key, &hot_replica_count); if (ret) goto out; @@ -916,7 +901,6 @@ gf_cli_get_volume_cbk (struct rpc_req *req, struct iovec *iov, goto out; case GF_CLI_GET_VOLUME: - memset (err_str, 0, sizeof (err_str)); snprintf (err_str, sizeof (err_str), "Volume %s does not exist", local->get_vol.volname); @@ -1045,7 +1029,6 @@ xml_output: #ifdef HAVE_BD_XLATOR k = 0; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.xlator%d", i, k); ret = dict_get_str (dict, key, &caps); if (ret) @@ -1054,7 +1037,6 @@ xml_output: j = 0; cli_out ("Xlator %d: %s", k + 1, caps); do { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.xlator%d.caps%d", i, k, j++); @@ -1064,7 +1046,6 @@ xml_output: cli_out ("Capability %d: %s", j, caps); } while (1); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.xlator%d", i, ++k); ret = dict_get_str (dict, key, &caps); @@ -1626,8 +1607,7 @@ gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type, goto out; } - memset (key, 0, 256); - snprintf (key, 256, "status-1"); + snprintf (key, sizeof (key), "status-1"); ret = dict_get_int32 (dict, key, (int32_t *)&status_rcd); if (ret) { @@ -1674,8 +1654,7 @@ gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type, time_left = 0; /* Check if status is NOT_STARTED, and continue early */ - memset (key, 0, 256); - snprintf (key, 256, "status-%d", i); + snprintf (key, sizeof (key), "status-%d", i); ret = dict_get_int32 (dict, key, (int32_t *)&status_rcd); if (ret == -ENOENT) { @@ -1704,36 +1683,31 @@ gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type, if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get node-name"); - memset (key, 0, 256); - snprintf (key, 256, "files-%d", i); + snprintf (key, sizeof (key), "files-%d", i); ret = dict_get_uint64 (dict, key, &files); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get file count"); - memset (key, 0, 256); - snprintf (key, 256, "size-%d", i); + snprintf (key, sizeof (key), "size-%d", i); ret = dict_get_uint64 (dict, key, &size); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get size of xfer"); - memset (key, 0, 256); - snprintf (key, 256, "lookups-%d", i); + snprintf (key, sizeof (key), "lookups-%d", i); ret = dict_get_uint64 (dict, key, &lookup); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get lookedup file count"); - memset (key, 0, 256); - snprintf (key, 256, "failures-%d", i); + snprintf (key, sizeof (key), "failures-%d", i); ret = dict_get_uint64 (dict, key, &failures); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get failures count"); - memset (key, 0, 256); - snprintf (key, 256, "skipped-%d", i); + snprintf (key, sizeof (key), "skipped-%d", i); ret = dict_get_uint64 (dict, key, &skipped); if (ret) gf_log ("cli", GF_LOG_TRACE, @@ -1745,14 +1719,12 @@ gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type, skipped = 0; } - memset (key, 0, 256); - snprintf (key, 256, "run-time-%d", i); + snprintf (key, sizeof (key), "run-time-%d", i); ret = dict_get_double (dict, key, &elapsed); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get run-time"); - memset (key, 0, 256); - snprintf (key, 256, "time-left-%d", i); + snprintf (key, sizeof (key), "time-left-%d", i); ret = dict_get_uint64 (dict, key, &time_left); if (ret) gf_log ("cli", GF_LOG_TRACE, @@ -1870,8 +1842,7 @@ gf_cli_print_tier_status (dict_t *dict, enum gf_task_types task_type) demoted = 0; /* Check if status is NOT_STARTED, and continue early */ - memset (key, 0, 256); - snprintf (key, 256, "status-%d", i); + snprintf (key, sizeof (key), "status-%d", i); ret = dict_get_int32 (dict, key, (int32_t *)&status_rcd); if (ret == -ENOENT) { @@ -1891,28 +1862,24 @@ gf_cli_print_tier_status (dict_t *dict, enum gf_task_types task_type) if (GF_DEFRAG_STATUS_NOT_STARTED == status_rcd) continue; - memset (key, 0, 256); - snprintf (key, 256, "node-name-%d", i); + snprintf (key, sizeof (key), "node-name-%d", i); ret = dict_get_str (dict, key, &node_name); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get node-name"); - memset (key, 0, 256); - snprintf (key, 256, "promoted-%d", i); + snprintf (key, sizeof (key), "promoted-%d", i); ret = dict_get_uint64 (dict, key, &promoted); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get promoted count"); - memset (key, 0, 256); - snprintf (key, 256, "demoted-%d", i); + snprintf (key, sizeof (key), "demoted-%d", i); ret = dict_get_uint64 (dict, key, &demoted); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get demoted count"); - memset (key, 0, 256); - snprintf (key, 256, "run-time-%d", i); + snprintf (key, sizeof (key), "run-time-%d", i); ret = dict_get_double (dict, key, &elapsed); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get run-time"); @@ -5528,25 +5495,21 @@ gf_cli_fsm_log_cbk (struct rpc_req *req, struct iovec *iov, else cli_err("No transitions"); for (i = 0; i < tr_count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "log%d-old-state", i); ret = dict_get_str (dict, key, &old_state); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "log%d-event", i); ret = dict_get_str (dict, key, &event); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "log%d-new-state", i); ret = dict_get_str (dict, key, &new_state); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "log%d-time", i); ret = dict_get_str (dict, key, &time); if (ret) @@ -5956,7 +5919,6 @@ write_contents_to_common_pem_file (dict_t *dict, int output_count) } for (i = 1; i <= output_count; i++) { - memset (output_name, '\0', sizeof (output_name)); snprintf (output_name, sizeof (output_name), "output_%d", i); ret = dict_get_str (dict, output_name, &output); @@ -6061,7 +6023,6 @@ gf_cli_sys_exec_cbk (struct rpc_req *req, struct iovec *iov, } for (i = 1; i <= output_count; i++) { - memset (output_name, '\0', sizeof (output_name)); snprintf (output_name, sizeof (output_name), "output_%d", i); ret = dict_get_str (dict, output_name, &output); @@ -6392,7 +6353,6 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval) double total_percentage_latency = 0; for (i = 0; i < 32; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-read-%d", count, interval, (1 << i)); ret = dict_get_uint64 (dict, key, &rb_counts[i]); @@ -6403,7 +6363,6 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval) } for (i = 0; i < 32; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-write-%d", count, interval, (1<<i)); ret = dict_get_uint64 (dict, key, &wb_counts[i]); @@ -6425,7 +6384,6 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval) } for (i = 0; i < GF_FOP_MAXVALUE; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-%d-hits", count, interval, i); ret = dict_get_uint64 (dict, key, &profile_info[i].fop_hits); @@ -6434,7 +6392,6 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval) "failed to get %s from dict", key); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-%d-avglatency", count, interval, i); ret = dict_get_double (dict, key, &profile_info[i].avg_latency); @@ -6443,7 +6400,6 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval) "failed to get %s from dict", key); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-%d-minlatency", count, interval, i); ret = dict_get_double (dict, key, &profile_info[i].min_latency); @@ -6452,7 +6408,6 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval) "failed to get %s from dict", key); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-%d-maxlatency", count, interval, i); ret = dict_get_double (dict, key, &profile_info[i].max_latency); @@ -6475,21 +6430,18 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval) sizeof (cli_profile_info_t), cli_profile_info_percentage_cmp); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-duration", count, interval); ret = dict_get_uint64 (dict, key, &sec); if (ret) { gf_log ("cli", GF_LOG_DEBUG, "failed to get %s from dict", key); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-total-read", count, interval); ret = dict_get_uint64 (dict, key, &r_count); if (ret) { gf_log ("cli", GF_LOG_DEBUG, "failed to get %s from dict", key); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-total-write", count, interval); ret = dict_get_uint64 (dict, key, &w_count); if (ret) { @@ -6530,9 +6482,6 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval) cli_out ("%s", write_blocks); cli_out (" "); per_line = 0; - memset (output, 0, sizeof (output)); - memset (read_blocks, 0, sizeof (read_blocks)); - memset (write_blocks, 0, sizeof (write_blocks)); snprintf (output, sizeof (output), "%14s", "Block Size:"); snprintf (read_blocks, sizeof (read_blocks), "%14s", "No. of Reads:"); @@ -6710,7 +6659,6 @@ gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov, } while (i <= brick_count) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-brick", i); ret = dict_get_str (dict, key, &brick); if (ret) { @@ -6894,7 +6842,6 @@ gf_cli_top_volume_cbk (struct rpc_req *req, struct iovec *iov, nfs = dict_get_str_boolean (dict, "nfs", _gf_false); if (clear_stats) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-stats-cleared", i); ret = dict_get_int32 (dict, key, &stats_cleared); if (ret) @@ -7130,7 +7077,6 @@ cli_print_volume_status_mempool (dict_t *dict, char *prefix) GF_ASSERT (dict); GF_ASSERT (prefix); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.mempool-count",prefix); ret = dict_get_int32 (dict, key, &mempool_count); if (ret) @@ -7145,50 +7091,42 @@ cli_print_volume_status_mempool (dict_t *dict, char *prefix) "--------", "--------", "------------"); for (i = 0; i < mempool_count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.name", prefix, i); ret = dict_get_str (dict, key, &name); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.hotcount", prefix, i); ret = dict_get_int32 (dict, key, &hotcount); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.coldcount", prefix, i); ret = dict_get_int32 (dict, key, &coldcount); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.paddedsizeof", prefix, i); ret = dict_get_uint64 (dict, key, &paddedsizeof); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.alloccount", prefix, i); ret = dict_get_uint64 (dict, key, &alloccount); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.max_alloc", prefix, i); ret = dict_get_int32 (dict, key, &maxalloc); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.max-stdalloc", prefix, i); ret = dict_get_int32 (dict, key, &maxstdalloc); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.pool-misses", prefix, i); ret = dict_get_uint64 (dict, key, &pool_misses); if (ret) @@ -7238,12 +7176,10 @@ cli_print_volume_status_mem (dict_t *dict, gf_boolean_t notbrick) for (i = 0; i <= index_max; i++) { cli_out ("----------------------------------------------"); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.hostname", i); ret = dict_get_str (dict, key, &hostname); if (ret) continue; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.path", i); ret = dict_get_str (dict, key, &path); if (ret) @@ -7253,7 +7189,6 @@ cli_print_volume_status_mem (dict_t *dict, gf_boolean_t notbrick) else cli_out ("Brick : %s:%s", hostname, path); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.status", i); ret = dict_get_int32 (dict, key, &online); if (ret) @@ -7268,70 +7203,60 @@ cli_print_volume_status_mem (dict_t *dict, gf_boolean_t notbrick) cli_out ("Mallinfo\n--------"); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.arena", i); ret = dict_get_int32 (dict, key, &val); if (ret) goto out; cli_out ("%-8s : %d","Arena", val); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.ordblks", i); ret = dict_get_int32 (dict, key, &val); if(ret) goto out; cli_out ("%-8s : %d","Ordblks", val); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.smblks", i); ret = dict_get_int32 (dict, key, &val); if(ret) goto out; cli_out ("%-8s : %d","Smblks", val); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.hblks", i); ret = dict_get_int32 (dict, key, &val); if(ret) goto out; cli_out ("%-8s : %d", "Hblks", val); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.hblkhd", i); ret = dict_get_int32 (dict, key, &val); if (ret) goto out; cli_out ("%-8s : %d", "Hblkhd", val); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.usmblks", i); ret = dict_get_int32 (dict, key, &val); if (ret) goto out; cli_out ("%-8s : %d", "Usmblks", val); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.fsmblks", i); ret = dict_get_int32 (dict, key, &val); if (ret) goto out; cli_out ("%-8s : %d", "Fsmblks", val); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.uordblks", i); ret = dict_get_int32 (dict, key, &val); if (ret) goto out; cli_out ("%-8s : %d", "Uordblks", val); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.fordblks", i); ret = dict_get_int32 (dict, key, &val); if (ret) goto out; cli_out ("%-8s : %d", "Fordblks", val); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.keepcost", i); ret = dict_get_int32 (dict, key, &val); if (ret) @@ -7339,7 +7264,6 @@ cli_print_volume_status_mem (dict_t *dict, gf_boolean_t notbrick) cli_out ("%-8s : %d", "Keepcost", val); cli_out (" "); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d", i); cli_print_volume_status_mempool (dict, key); } @@ -7382,7 +7306,6 @@ cli_print_volume_status_client_list (dict_t *dict, gf_boolean_t notbrick) cli_out ("%-48s %15s", "-----", "------"); for (i = 0; i < client_count; i++) { name = NULL; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.name", i); ret = dict_get_str (dict, key, &name); @@ -7530,11 +7453,9 @@ cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) cli_out ("----------------------------------------------"); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.hostname", i); ret = dict_get_str (dict, key, &hostname); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.path", i); ret = dict_get_str (dict, key, &path); @@ -7544,7 +7465,6 @@ cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) else cli_out ("Brick : %s:%s", hostname, path); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.status", i); ret = dict_get_int32 (dict, key, &online); if (!online) { @@ -7555,7 +7475,6 @@ cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) continue; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.clientcount", i); ret = dict_get_int32 (dict, key, &client_count); @@ -7569,22 +7488,18 @@ cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) cli_out ("%-48s %15s %15s %15s", "--------", "---------", "------------", "---------"); for (j =0; j < client_count; j++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.client%d.hostname", i, j); ret = dict_get_str (dict, key, &clientname); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.client%d.bytesread", i, j); ret = dict_get_uint64 (dict, key, &bytesread); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.client%d.byteswrite", i, j); ret = dict_get_uint64 (dict, key, &byteswrite); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.client%d.opversion", i, j); ret = dict_get_uint32 (dict, key, &opversion); @@ -7613,25 +7528,21 @@ cli_print_volume_status_inode_entry (dict_t *dict, char *prefix) GF_ASSERT (dict); GF_ASSERT (prefix); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.gfid", prefix); ret = dict_get_str (dict, key, &gfid); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.nlookup", prefix); ret = dict_get_uint64 (dict, key, &nlookup); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.ref", prefix); ret = dict_get_uint32 (dict, key, &ref); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.ia_type", prefix); ret = dict_get_int32 (dict, key, &ia_type); if (ret) @@ -7685,7 +7596,6 @@ cli_print_volume_status_itables (dict_t *dict, char *prefix) GF_ASSERT (dict); GF_ASSERT (prefix); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.active_size", prefix); ret = dict_get_uint32 (dict, key, &active_size); if (ret) @@ -7698,13 +7608,11 @@ cli_print_volume_status_itables (dict_t *dict, char *prefix) "-------"); } for (i = 0; i < active_size; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.active%d", prefix, i); cli_print_volume_status_inode_entry (dict, key); } cli_out (" "); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.lru_size", prefix); ret = dict_get_uint32 (dict, key, &lru_size); if (ret) @@ -7717,13 +7625,11 @@ cli_print_volume_status_itables (dict_t *dict, char *prefix) "-------"); } for (i = 0; i < lru_size; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.lru%d", prefix, i); cli_print_volume_status_inode_entry (dict, key); } cli_out (" "); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.purge_size", prefix); ret = dict_get_uint32 (dict, key, &purge_size); if (ret) @@ -7736,7 +7642,6 @@ cli_print_volume_status_itables (dict_t *dict, char *prefix) "-------"); } for (i = 0; i < purge_size; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.purge%d", prefix, i); cli_print_volume_status_inode_entry (dict, key); } @@ -7780,12 +7685,10 @@ cli_print_volume_status_inode (dict_t *dict, gf_boolean_t notbrick) for ( i = 0; i <= index_max; i++) { cli_out ("----------------------------------------------"); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.hostname", i); ret = dict_get_str (dict, key, &hostname); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.path", i); ret = dict_get_str (dict, key, &path); if (ret) @@ -7795,7 +7698,6 @@ cli_print_volume_status_inode (dict_t *dict, gf_boolean_t notbrick) else cli_out ("Brick : %s:%s", hostname, path); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.status", i); ret = dict_get_int32 (dict, key, &online); if (ret) @@ -7808,7 +7710,6 @@ cli_print_volume_status_inode (dict_t *dict, gf_boolean_t notbrick) continue; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.conncount", i); ret = dict_get_int32 (dict, key, &conn_count); if (ret) @@ -7818,7 +7719,6 @@ cli_print_volume_status_inode (dict_t *dict, gf_boolean_t notbrick) if (conn_count > 1) cli_out ("Connection %d:", j+1); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.conn%d.itable", i, j); cli_print_volume_status_itables (dict, key); @@ -7847,19 +7747,16 @@ cli_print_volume_status_fdtable (dict_t *dict, char *prefix) GF_ASSERT (dict); GF_ASSERT (prefix); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.refcount", prefix); ret = dict_get_int32 (dict, key, &refcount); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.maxfds", prefix); ret = dict_get_uint32 (dict, key, &maxfds); if (ret) goto out; - memset (key, 0 ,sizeof (key)); snprintf (key, sizeof (key), "%s.firstfree", prefix); ret = dict_get_int32 (dict, key, &firstfree); if (ret) @@ -7868,7 +7765,6 @@ cli_print_volume_status_fdtable (dict_t *dict, char *prefix) cli_out ("RefCount = %d MaxFDs = %d FirstFree = %d", refcount, maxfds, firstfree); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.openfds", prefix); ret = dict_get_int32 (dict, key, &openfds); if (ret) @@ -7884,20 +7780,17 @@ cli_print_volume_status_fdtable (dict_t *dict, char *prefix) "--------", "-----"); for (i = 0; i < maxfds ; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fdentry%d.pid", prefix, i); ret = dict_get_int32 (dict, key, &fd_pid); if (ret) continue; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fdentry%d.refcount", prefix, i); ret = dict_get_int32 (dict, key, &fd_refcount); if (ret) continue; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fdentry%d.flags", prefix, i); ret = dict_get_int32 (dict, key, &fd_flags); if (ret) @@ -7946,12 +7839,10 @@ cli_print_volume_status_fd (dict_t *dict, gf_boolean_t notbrick) for (i = 0; i <= index_max; i++) { cli_out ("----------------------------------------------"); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.hostname", i); ret = dict_get_str (dict, key, &hostname); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.path", i); ret = dict_get_str (dict, key, &path); if (ret) @@ -7962,7 +7853,6 @@ cli_print_volume_status_fd (dict_t *dict, gf_boolean_t notbrick) else cli_out ("Brick : %s:%s", hostname, path); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.status", i); ret = dict_get_int32 (dict, key, &online); if (ret) @@ -7975,7 +7865,6 @@ cli_print_volume_status_fd (dict_t *dict, gf_boolean_t notbrick) continue; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.conncount", i); ret = dict_get_int32 (dict, key, &conn_count); if (ret) @@ -7984,7 +7873,6 @@ cli_print_volume_status_fd (dict_t *dict, gf_boolean_t notbrick) for (j = 0; j < conn_count; j++) { cli_out ("Connection %d:", j+1); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.conn%d.fdtable", i, j); cli_print_volume_status_fdtable (dict, key); @@ -8013,19 +7901,16 @@ cli_print_volume_status_call_frame (dict_t *dict, char *prefix) if (!dict || !prefix) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.refcount", prefix); ret = dict_get_int32 (dict, key, &ref_count); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.translator", prefix); ret = dict_get_str (dict, key, &translator); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.complete", prefix); ret = dict_get_int32 (dict, key, &complete); if (ret) @@ -8035,31 +7920,26 @@ cli_print_volume_status_call_frame (dict_t *dict, char *prefix) cli_out (" Translator = %s", translator); cli_out (" Completed = %s", (complete ? "Yes" : "No")); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.parent", prefix); ret = dict_get_str (dict, key, &parent); if (!ret) cli_out (" Parent = %s", parent); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.windfrom", prefix); ret = dict_get_str (dict, key, &wind_from); if (!ret) cli_out (" Wind From = %s", wind_from); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.windto", prefix); ret = dict_get_str (dict, key, &wind_to); if (!ret) cli_out (" Wind To = %s", wind_to); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.unwindfrom", prefix); ret = dict_get_str (dict, key, &unwind_from); if (!ret) cli_out (" Unwind From = %s", unwind_from); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.unwindto", prefix); ret = dict_get_str (dict, key, &unwind_to); if (!ret) @@ -8082,32 +7962,27 @@ cli_print_volume_status_call_stack (dict_t *dict, char *prefix) if (!dict || !prefix) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.uid", prefix); ret = dict_get_int32 (dict, key, &uid); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.gid", prefix); ret = dict_get_int32 (dict, key, &gid); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pid", prefix); ret = dict_get_int32 (dict, key, &pid); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.unique", prefix); ret = dict_get_uint64 (dict, key, &unique); if (ret) return; /* - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.op", prefix); ret = dict_get_str (dict, key, &op); if (ret) @@ -8115,7 +7990,6 @@ cli_print_volume_status_call_stack (dict_t *dict, char *prefix) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.count", prefix); ret = dict_get_int32 (dict, key, &count); if (ret) @@ -8131,7 +8005,6 @@ cli_print_volume_status_call_stack (dict_t *dict, char *prefix) for (i = 0; i < count; i++) { cli_out (" Frame %d", i+1); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.frame%d", prefix, i); cli_print_volume_status_call_frame (dict, key); } @@ -8174,12 +8047,10 @@ cli_print_volume_status_callpool (dict_t *dict, gf_boolean_t notbrick) for (i = 0; i <= index_max; i++) { cli_out ("----------------------------------------------"); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.hostname", i); ret = dict_get_str (dict, key, &hostname); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.path", i); ret = dict_get_str (dict, key, &path); if (ret) @@ -8190,7 +8061,6 @@ cli_print_volume_status_callpool (dict_t *dict, gf_boolean_t notbrick) else cli_out ("Brick : %s:%s", hostname, path); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.status", i); ret = dict_get_int32 (dict, key, &online); if (ret) @@ -8203,7 +8073,6 @@ cli_print_volume_status_callpool (dict_t *dict, gf_boolean_t notbrick) continue; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.callpool.count", i); ret = dict_get_int32 (dict, key, &call_count); if (ret) @@ -8216,7 +8085,6 @@ cli_print_volume_status_callpool (dict_t *dict, gf_boolean_t notbrick) for (j = 0; j < call_count; j++) { cli_out ("Call Stack%d", j+1); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.callpool.stack%d", i, j); cli_print_volume_status_call_stack (dict, key); @@ -8264,21 +8132,18 @@ cli_print_volume_status_tasks (dict_t *dict) } for (i = 0; i < task_count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.type", i); ret = dict_get_str(dict, key, &op); if (ret) return; cli_out ("%-20s : %-20s", "Task", op); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.id", i); ret = dict_get_str (dict, key, &task_id_str); if (ret) return; cli_out ("%-20s : %-20s", "ID", task_id_str); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.status", i); ret = dict_get_int32 (dict, key, &status); if (ret) @@ -8287,7 +8152,6 @@ cli_print_volume_status_tasks (dict_t *dict) snprintf (task, sizeof (task), "task%d", i); if (!strcmp (op, "Remove brick")) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.count", task); ret = dict_get_int32 (dict, key, &count); if (ret) @@ -8296,7 +8160,6 @@ cli_print_volume_status_tasks (dict_t *dict) cli_out ("%-20s", "Removed bricks:"); for (j = 1; j <= count; j++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key),"%s.brick%d", task, j); ret = dict_get_str (dict, key, &brick); @@ -8542,13 +8405,11 @@ xml_end: } status.rdma_port = 0; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.hostname", i); ret = dict_get_str (dict, key, &hostname); if (ret) continue; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.path", i); ret = dict_get_str (dict, key, &path); if (ret) @@ -8568,7 +8429,6 @@ xml_end: snprintf (status.brick, PATH_MAX + 255, "%s on %s", hostname, path); else { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.rdma_port", i); ret = dict_get_int32 (dict, key, &(status.rdma_port)); if (ret) @@ -8577,19 +8437,16 @@ xml_end: hostname, path); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.port", i); ret = dict_get_int32 (dict, key, &(status.port)); if (ret) continue; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.status", i); ret = dict_get_int32 (dict, key, &(status.online)); if (ret) continue; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.pid", i); ret = dict_get_int32 (dict, key, &pid); if (ret) @@ -8722,7 +8579,6 @@ gf_cli_status_volume_all (call_frame_t *frame, xlator_t *this, void *data) if (!dict) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "vol%d", i); ret = dict_get_str (vol_dict, key, &volname); if (ret) @@ -9482,7 +9338,6 @@ gf_cli_list_volume_cbk (struct rpc_req *req, struct iovec *iov, goto out; } for (i = 0; i < vol_count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d", i); ret = dict_get_str (dict, key, &volname); if (ret) @@ -11939,7 +11794,6 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict) } for (i = 1; i <= count; i++) { - memset (key, 0, 256); snprintf (key, 256, "scrub-running-%d", i); ret = dict_get_int8 (dict, key, &scrub_running); if (ret) @@ -11980,40 +11834,34 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict) scrub_files = 0; unsigned_files = 0; - memset (key, 0, 256); snprintf (key, 256, "node-name-%d", i); ret = dict_get_str (dict, key, &node_name); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get node-name"); - memset (key, 0, 256); snprintf (key, 256, "scrubbed-files-%d", i); ret = dict_get_uint64 (dict, key, &scrub_files); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get scrubbed " "files"); - memset (key, 0, 256); snprintf (key, 256, "unsigned-files-%d", i); ret = dict_get_uint64 (dict, key, &unsigned_files); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get unsigned " "files"); - memset (key, 0, 256); snprintf (key, 256, "scrub-duration-%d", i); ret = dict_get_uint64 (dict, key, &scrub_time); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get last scrub " "duration"); - memset (key, 0, 256); snprintf (key, 256, "last-scrub-time-%d", i); ret = dict_get_str (dict, key, &last_scrub); if (ret) gf_log ("cli", GF_LOG_TRACE, "failed to get last scrub" " time"); - memset (key, 0, 256); snprintf (key, 256, "error-count-%d", i); ret = dict_get_uint64 (dict, key, &error_count); if (ret) @@ -12053,7 +11901,6 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict) cli_out ("%s:\n", "Corrupted object's [GFID]"); /* Printing list of bad file's (Corrupted object's)*/ for (j = 0; j < error_count; j++) { - memset (key, 0, 256); snprintf (key, 256, "quarantine-%d-%d", j, i); ret = dict_get_str (dict, key, &bad_file_str); if (!ret) { diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index ec65cd30f5e..4f912f81043 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -270,7 +270,6 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict, "%s", hostname); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.path", brick_index); ret = dict_get_str (dict, key, &path); if (ret) @@ -279,7 +278,6 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict, "%s", path); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.peerid", brick_index); ret = dict_get_str (dict, key, &uuid); if (ret) @@ -288,7 +286,6 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict, "%s", uuid); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.status", brick_index); ret = dict_get_int32 (dict, key, &status); if (ret) @@ -298,13 +295,11 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); *online = status; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.port", brick_index); ret = dict_get_int32 (dict, key, &port); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.rdma_port", brick_index); ret = dict_get_int32 (dict, key, &rdma_port); @@ -364,7 +359,6 @@ cli_xml_output_vol_status_common (xmlTextWriterPtr writer, dict_t *dict, ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.pid", brick_index); ret = dict_get_int32 (dict, key, &pid); if (ret) @@ -402,7 +396,6 @@ cli_xml_output_vol_status_detail (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, size_total); XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.free", brick_index); ret = dict_get_uint64 (dict, key, &size_free); if (!ret) { @@ -411,7 +404,6 @@ cli_xml_output_vol_status_detail (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, size_free); XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.device", brick_index); ret = dict_get_str (dict, key, &device); if (!ret) { @@ -420,7 +412,6 @@ cli_xml_output_vol_status_detail (xmlTextWriterPtr writer, dict_t *dict, "%s", device); XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.block_size", brick_index); ret = dict_get_uint64 (dict, key, &block_size); if (!ret) { @@ -429,7 +420,6 @@ cli_xml_output_vol_status_detail (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, block_size); XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mnt_options", brick_index); ret = dict_get_str (dict, key, &mnt_options); if (!ret) { @@ -438,7 +428,6 @@ cli_xml_output_vol_status_detail (xmlTextWriterPtr writer, dict_t *dict, "%s", mnt_options); XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.fs_name", brick_index); ret = dict_get_str (dict, key, &fs_name); if (!ret) { @@ -447,7 +436,6 @@ cli_xml_output_vol_status_detail (xmlTextWriterPtr writer, dict_t *dict, "%s", fs_name); XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.inode_size", brick_index); ret = dict_get_str (dict, key, &inode_size); if (!ret) { @@ -456,7 +444,6 @@ cli_xml_output_vol_status_detail (xmlTextWriterPtr writer, dict_t *dict, "%s", fs_name); XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.total_inodes", brick_index); ret = dict_get_uint64 (dict, key, &inodes_total); if (!ret) { @@ -465,7 +452,6 @@ cli_xml_output_vol_status_detail (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, inodes_total); XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.free_inodes", brick_index); ret = dict_get_uint64 (dict, key, &inodes_free); if (!ret) { @@ -514,7 +500,6 @@ cli_xml_output_vol_status_mempool (xmlTextWriterPtr writer, dict_t *dict, ret = xmlTextWriterStartElement (writer, (xmlChar *)"pool"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.name", prefix, i); ret = dict_get_str (dict, key, &name); if (ret) @@ -524,7 +509,6 @@ cli_xml_output_vol_status_mempool (xmlTextWriterPtr writer, dict_t *dict, "%s", name); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.hotcount", prefix, i); ret = dict_get_int32 (dict, key, &hotcount); if (ret) @@ -534,7 +518,6 @@ cli_xml_output_vol_status_mempool (xmlTextWriterPtr writer, dict_t *dict, "%d", hotcount); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.coldcount", prefix, i); ret = dict_get_int32 (dict, key, &coldcount); if (ret) @@ -544,7 +527,6 @@ cli_xml_output_vol_status_mempool (xmlTextWriterPtr writer, dict_t *dict, "%d", coldcount); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.paddedsizeof", prefix, i); ret = dict_get_uint64 (dict, key, &paddedsizeof); @@ -555,7 +537,6 @@ cli_xml_output_vol_status_mempool (xmlTextWriterPtr writer, dict_t *dict, paddedsizeof); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.alloccount", prefix, i); ret = dict_get_uint64 (dict, key, &alloccount); if (ret) @@ -565,7 +546,6 @@ cli_xml_output_vol_status_mempool (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, alloccount); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.max_alloc", prefix, i); ret = dict_get_int32 (dict, key, &maxalloc); if (ret) @@ -575,7 +555,6 @@ cli_xml_output_vol_status_mempool (xmlTextWriterPtr writer, dict_t *dict, "%d", maxalloc); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.pool-misses", prefix, i); ret = dict_get_uint64 (dict, key, &alloccount); if (ret) @@ -585,7 +564,6 @@ cli_xml_output_vol_status_mempool (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, alloccount); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pool%d.max-stdalloc", prefix, i); ret = dict_get_int32 (dict, key, &maxalloc); if (ret) @@ -643,7 +621,6 @@ cli_xml_output_vol_status_mem (xmlTextWriterPtr writer, dict_t *dict, "%d", arena); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.ordblks", brick_index); ret = dict_get_int32 (dict, key, &ordblks); if (ret) @@ -652,7 +629,6 @@ cli_xml_output_vol_status_mem (xmlTextWriterPtr writer, dict_t *dict, "%d", ordblks); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.smblks", brick_index); ret = dict_get_int32 (dict, key, &smblks); if (ret) @@ -661,7 +637,6 @@ cli_xml_output_vol_status_mem (xmlTextWriterPtr writer, dict_t *dict, "%d", smblks); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.hblks", brick_index); ret = dict_get_int32 (dict, key, &hblks); if (ret) @@ -670,7 +645,6 @@ cli_xml_output_vol_status_mem (xmlTextWriterPtr writer, dict_t *dict, "%d", hblks); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.hblkhd", brick_index); ret = dict_get_int32 (dict, key, &hblkhd); if (ret) @@ -679,7 +653,6 @@ cli_xml_output_vol_status_mem (xmlTextWriterPtr writer, dict_t *dict, "%d", hblkhd); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.usmblks", brick_index); ret = dict_get_int32 (dict, key, &usmblks); if (ret) @@ -688,7 +661,6 @@ cli_xml_output_vol_status_mem (xmlTextWriterPtr writer, dict_t *dict, "%d", usmblks); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.fsmblks", brick_index); ret = dict_get_int32 (dict, key, &fsmblks); if (ret) @@ -697,7 +669,6 @@ cli_xml_output_vol_status_mem (xmlTextWriterPtr writer, dict_t *dict, "%d", fsmblks); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.uordblks", brick_index); ret = dict_get_int32 (dict, key, &uordblks); if (ret) @@ -706,7 +677,6 @@ cli_xml_output_vol_status_mem (xmlTextWriterPtr writer, dict_t *dict, "%d", uordblks); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.fordblks", brick_index); ret = dict_get_int32 (dict, key, &fordblks); if (ret) @@ -715,7 +685,6 @@ cli_xml_output_vol_status_mem (xmlTextWriterPtr writer, dict_t *dict, "%d", fordblks); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.mallinfo.keepcost", brick_index); ret = dict_get_int32 (dict, key, &keepcost); if (ret) @@ -728,7 +697,6 @@ cli_xml_output_vol_status_mem (xmlTextWriterPtr writer, dict_t *dict, ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d", brick_index); ret = cli_xml_output_vol_status_mempool (writer, dict, key); if (ret) @@ -774,7 +742,6 @@ cli_xml_output_vol_status_clients (xmlTextWriterPtr writer, dict_t *dict, ret = xmlTextWriterStartElement (writer, (xmlChar *)"client"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.client%d.hostname", brick_index, i); ret = dict_get_str (dict, key, &hostname); @@ -785,7 +752,6 @@ cli_xml_output_vol_status_clients (xmlTextWriterPtr writer, dict_t *dict, "%s", hostname); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.client%d.bytesread", brick_index, i); ret = dict_get_uint64 (dict, key, &bytes_read); @@ -796,7 +762,6 @@ cli_xml_output_vol_status_clients (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, bytes_read); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.client%d.byteswrite", brick_index, i); ret = dict_get_uint64 (dict, key, &bytes_write); @@ -807,7 +772,6 @@ cli_xml_output_vol_status_clients (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, bytes_write); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.client%d.opversion", brick_index, i); ret = dict_get_uint32 (dict, key, &opversion); @@ -854,7 +818,6 @@ cli_xml_output_vol_status_inode_entry (xmlTextWriterPtr writer, dict_t *dict, "%s", gfid); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key,0, sizeof (key)); snprintf (key, sizeof (key), "%s.nlookup", prefix); ret = dict_get_uint64 (dict, key, &nlookup); if (ret) @@ -863,7 +826,6 @@ cli_xml_output_vol_status_inode_entry (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, nlookup); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key,0, sizeof (key)); snprintf (key, sizeof (key), "%s.ref", prefix); ret = dict_get_uint32 (dict, key, &ref); if (ret) @@ -872,7 +834,6 @@ cli_xml_output_vol_status_inode_entry (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu32, ref); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key,0, sizeof (key)); snprintf (key, sizeof (key), "%s.ia_type", prefix); ret = dict_get_int32 (dict, key, &ia_type); if (ret) @@ -914,7 +875,6 @@ cli_xml_output_vol_status_itable (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); for (i = 0; i < active_size; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.active%d", prefix, i); ret = cli_xml_output_vol_status_inode_entry (writer, dict, key); @@ -926,7 +886,6 @@ cli_xml_output_vol_status_itable (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.lru_size", prefix); ret = dict_get_uint32 (dict, key, &lru_size); if (ret) @@ -940,7 +899,6 @@ cli_xml_output_vol_status_itable (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); for (i = 0; i < lru_size; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.lru%d", prefix, i); ret = cli_xml_output_vol_status_inode_entry (writer, dict, key); @@ -952,7 +910,6 @@ cli_xml_output_vol_status_itable (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.purge_size", prefix); ret = dict_get_uint32 (dict, key, &purge_size); if (ret) @@ -966,7 +923,6 @@ cli_xml_output_vol_status_itable (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); for (i = 0; i < purge_size; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.purge%d", prefix, i); ret = cli_xml_output_vol_status_inode_entry (writer, dict, key); @@ -1010,7 +966,6 @@ cli_xml_output_vol_status_inode (xmlTextWriterPtr writer, dict_t *dict, (xmlChar *)"connection"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.conn%d.itable", brick_index, i); ret = cli_xml_output_vol_status_itable (writer, dict, key); @@ -1058,7 +1013,6 @@ cli_xml_output_vol_status_fdtable (xmlTextWriterPtr writer, dict_t *dict, "%d", refcount); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.maxfds", prefix); ret = dict_get_uint32 (dict, key, &maxfds); if (ret) @@ -1067,7 +1021,6 @@ cli_xml_output_vol_status_fdtable (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu32, maxfds); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.firstfree", prefix); ret = dict_get_int32 (dict, key, &firstfree); if (ret) @@ -1076,7 +1029,6 @@ cli_xml_output_vol_status_fdtable (xmlTextWriterPtr writer, dict_t *dict, "%d", firstfree); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.openfds", prefix); ret = dict_get_int32 (dict, key, &openfds); if (ret) @@ -1086,20 +1038,17 @@ cli_xml_output_vol_status_fdtable (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); for (i = 0; i < maxfds; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fdentry%d.pid", prefix, i); ret = dict_get_int32 (dict, key, &fd_pid); if (ret) continue; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fdentry%d.refcount", prefix, i); ret = dict_get_int32 (dict, key, &fd_refcount); if (ret) continue; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fdentry%d.flags", prefix, i); ret = dict_get_int32 (dict, key, &fd_flags); if (ret) @@ -1170,7 +1119,6 @@ cli_xml_output_vol_status_fd (xmlTextWriterPtr writer, dict_t *dict, (xmlChar *)"connection"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.conn%d.fdtable", brick_index, i); ret = cli_xml_output_vol_status_fdtable (writer, dict, key); @@ -1218,7 +1166,6 @@ cli_xml_output_vol_status_callframe (xmlTextWriterPtr writer, dict_t *dict, "%d", ref_count); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.translator", prefix); ret = dict_get_str (dict, key, &translator); if (ret) @@ -1227,7 +1174,6 @@ cli_xml_output_vol_status_callframe (xmlTextWriterPtr writer, dict_t *dict, "%s", translator); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.complete", prefix); ret = dict_get_int32 (dict, key, &complete); if (ret) @@ -1236,7 +1182,6 @@ cli_xml_output_vol_status_callframe (xmlTextWriterPtr writer, dict_t *dict, "%d", complete); XML_RET_CHECK_AND_GOTO (ret ,out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.parent", prefix); ret = dict_get_str (dict, key, &parent); if (!ret) { @@ -1246,7 +1191,6 @@ cli_xml_output_vol_status_callframe (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.windfrom", prefix); ret = dict_get_str (dict, key, &wind_from); if (!ret) { @@ -1256,7 +1200,6 @@ cli_xml_output_vol_status_callframe (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.windto", prefix); ret = dict_get_str (dict, key, &wind_to); if (!ret) { @@ -1266,7 +1209,6 @@ cli_xml_output_vol_status_callframe (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.unwindfrom", prefix); ret = dict_get_str (dict, key, &unwind_from); if (!ret) { @@ -1276,7 +1218,6 @@ cli_xml_output_vol_status_callframe (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.unwindto", prefix); ret = dict_get_str (dict, key, &unwind_to); if (!ret) { @@ -1319,7 +1260,6 @@ cli_xml_output_vol_status_callstack (xmlTextWriterPtr writer, dict_t *dict, "%d", uid); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.gid", prefix); ret = dict_get_int32 (dict, key, &gid); if (ret) @@ -1328,7 +1268,6 @@ cli_xml_output_vol_status_callstack (xmlTextWriterPtr writer, dict_t *dict, "%d", gid); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pid", prefix); ret = dict_get_int32 (dict, key, &pid); if (ret) @@ -1337,7 +1276,6 @@ cli_xml_output_vol_status_callstack (xmlTextWriterPtr writer, dict_t *dict, "%d", pid); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.unique", prefix); ret = dict_get_uint64 (dict, key, &unique); if (ret) @@ -1346,7 +1284,6 @@ cli_xml_output_vol_status_callstack (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, unique); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.count", prefix); ret = dict_get_int32 (dict, key, &frame_count); if (ret) @@ -1356,7 +1293,6 @@ cli_xml_output_vol_status_callstack (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); for (i = 0; i < frame_count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.frame%d", prefix, i); ret = cli_xml_output_vol_status_callframe (writer, dict, key); @@ -1394,7 +1330,6 @@ cli_xml_output_vol_status_callpool (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); for (i = 0; i < call_count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.callpool.stack%d", brick_index, i); ret = cli_xml_output_vol_status_callstack (writer, dict, @@ -1488,7 +1423,6 @@ cli_xml_output_remove_brick_task_params (xmlTextWriterPtr writer, dict_t *dict, goto out; for (i = 1; i <= count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.brick%d", prefix, i); ret = dict_get_str (dict, key, &brick); if (ret) @@ -1532,7 +1466,6 @@ cli_xml_output_vol_status_tasks (cli_local_t *local, dict_t *dict) { (xmlChar *)"task"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.type", i); ret = dict_get_str (dict, key, &task_type); if (ret) @@ -1542,7 +1475,6 @@ cli_xml_output_vol_status_tasks (cli_local_t *local, dict_t *dict) { "%s", task_type); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.id", i); ret = dict_get_str (dict, key, &task_id_str); if (ret) @@ -1552,7 +1484,6 @@ cli_xml_output_vol_status_tasks (cli_local_t *local, dict_t *dict) { "%s", task_id_str); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.status", i); ret = dict_get_int32 (dict, key, &status); if (ret) @@ -1569,7 +1500,6 @@ cli_xml_output_vol_status_tasks (cli_local_t *local, dict_t *dict) { XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d", i); if (!strcmp (task_type, "Remove brick")) { ret = cli_xml_output_remove_brick_task_params @@ -1830,7 +1760,6 @@ cli_xml_output_vol_top_rw_perf (xmlTextWriterPtr writer, dict_t *dict, "%s", filename); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-value-%d", brick_index, member_index); ret = dict_get_uint64 (dict, key, &throughput); if (ret) @@ -1839,14 +1768,12 @@ cli_xml_output_vol_top_rw_perf (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, throughput); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-time-sec-%d", brick_index, member_index); ret = dict_get_int32 (dict, key, (int32_t *)&time_sec); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-time-usec-%d", brick_index, member_index); ret = dict_get_int32 (dict, key, (int32_t *)&time_usec); @@ -1892,7 +1819,6 @@ cli_xml_output_vol_top_other (xmlTextWriterPtr writer, dict_t *dict, "%s", filename); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-value-%d", brick_index, member_index); ret = dict_get_uint64 (dict, key, &count); if (ret) @@ -1965,7 +1891,6 @@ cli_xml_output_vol_top (dict_t *dict, int op_ret, int op_errno, ret = xmlTextWriterStartElement (writer, (xmlChar *)"brick"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-brick", i); ret = dict_get_str (dict, key, &brick_name); if (ret) @@ -1975,7 +1900,6 @@ cli_xml_output_vol_top (dict_t *dict, int op_ret, int op_errno, "%s", brick_name); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key , sizeof (key), "%d-members", i); ret = dict_get_int32 (dict, key, &members); if (ret) @@ -1987,7 +1911,6 @@ cli_xml_output_vol_top (dict_t *dict, int op_ret, int op_errno, switch (top_op) { case GF_CLI_TOP_OPEN: - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-current-open", i); ret = dict_get_uint64 (dict, key, ¤t_open); if (ret) @@ -1997,7 +1920,6 @@ cli_xml_output_vol_top (dict_t *dict, int op_ret, int op_errno, current_open); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-max-open", i); ret = dict_get_uint64 (dict, key, &max_open); if (ret) @@ -2007,7 +1929,6 @@ cli_xml_output_vol_top (dict_t *dict, int op_ret, int op_errno, max_open); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-max-openfd-time", i); ret = dict_get_str (dict, key, &max_open_time); if (ret) @@ -2026,11 +1947,9 @@ cli_xml_output_vol_top (dict_t *dict, int op_ret, int op_errno, case GF_CLI_TOP_READ_PERF: case GF_CLI_TOP_WRITE_PERF: - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-throughput", i); ret = dict_get_double (dict, key, &throughput); if (!ret) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-time", i); ret = dict_get_double (dict, key, &time_taken); } @@ -2126,7 +2045,6 @@ cli_xml_output_vol_profile_stats (xmlTextWriterPtr writer, dict_t *dict, (writer, (xmlChar *)"size", "%"PRIu32, (1 << i)); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-read-%d", brick_index, interval, (1 << i)); ret = dict_get_uint64 (dict, key, &read_count); @@ -2136,7 +2054,6 @@ cli_xml_output_vol_profile_stats (xmlTextWriterPtr writer, dict_t *dict, (writer, (xmlChar *)"reads", "%"PRIu64, read_count); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-write-%d", brick_index, interval, (1 << i)); ret = dict_get_uint64 (dict, key, &write_count); @@ -2160,28 +2077,24 @@ cli_xml_output_vol_profile_stats (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); for (i = 0; i < GF_FOP_MAXVALUE; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-%d-hits", brick_index, interval, i); ret = dict_get_uint64 (dict, key, &hits); if (ret) goto cont; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-%d-avglatency", brick_index, interval, i); ret = dict_get_double (dict, key, &avg_latency); if (ret) goto cont; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-%d-minlatency", brick_index, interval, i); ret = dict_get_double (dict, key, &min_latency); if (ret) goto cont; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-%d-maxlatency", brick_index, interval, i); ret = dict_get_double (dict, key, &max_latency); @@ -2229,7 +2142,6 @@ cont: min_latency = 0.0; max_latency = 0.0; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-%d-upcall-hits", brick_index, interval, i); ret = dict_get_uint64 (dict, key, &hits); @@ -2269,7 +2181,6 @@ cont: ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-duration", brick_index, interval); ret = dict_get_uint64 (dict, key, &duration); if (ret) @@ -2278,7 +2189,6 @@ cont: "%"PRIu64, duration); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-total-read", brick_index, interval); ret = dict_get_uint64 (dict, key, &total_read); if (ret) @@ -2287,7 +2197,6 @@ cont: "%"PRIu64, total_read); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-%d-total-write", brick_index, interval); ret = dict_get_uint64 (dict, key, &total_write); if (ret) @@ -2400,7 +2309,6 @@ cli_xml_output_vol_profile (dict_t *dict, int op_ret, int op_errno, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-interval", i); ret = dict_get_int32 (dict, key, &interval); if (ret == 0) { @@ -2463,7 +2371,6 @@ cli_xml_output_vol_list (dict_t *dict, int op_ret, int op_errno, XML_RET_CHECK_AND_GOTO (ret, out); for (i = 0; i < count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d", i); ret = dict_get_str (dict, key, &volname); if (ret) @@ -2656,7 +2563,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) (xmlChar *)"volume"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.name", i); ret = dict_get_str (dict, key, &volname); if (ret) @@ -2666,7 +2572,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%s", volname); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.volume_id", i); ret = dict_get_str (dict, key, &volume_id); if (ret) @@ -2676,7 +2581,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%s", volume_id); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.status", i); ret = dict_get_int32 (dict, key, &status); if (ret) @@ -2691,7 +2595,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) cli_vol_status_str[status]); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.snap_count", i); ret = dict_get_int32 (dict, key, &snap_count); if (ret) @@ -2702,7 +2605,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.brick_count", i); ret = dict_get_int32 (dict, key, &brick_count); if (ret) @@ -2712,7 +2614,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%d", brick_count); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.dist_count", i); ret = dict_get_int32 (dict, key, &dist_count); if (ret) @@ -2722,7 +2623,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%d", dist_count); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.stripe_count", i); ret = dict_get_int32 (dict, key, &stripe_count); if (ret) @@ -2732,7 +2632,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%d", stripe_count); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.replica_count", i); ret = dict_get_int32 (dict, key, &replica_count); if (ret) @@ -2742,7 +2641,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%d", replica_count); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.arbiter_count", i); ret = dict_get_int32 (dict, key, &arbiter_count); if (ret) @@ -2752,7 +2650,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%d", arbiter_count); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.disperse_count", i); ret = dict_get_int32 (dict, key, &disperse_count); if (ret) @@ -2762,7 +2659,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%d", disperse_count); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.redundancy_count", i); ret = dict_get_int32 (dict, key, &redundancy_count); if (ret) @@ -2772,7 +2668,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%d", redundancy_count); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.type", i); ret = dict_get_int32 (dict, key, &type); if (ret) @@ -2793,7 +2688,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) vol_type_str[type]); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.transport", i); ret = dict_get_int32 (dict, key, &transport); if (ret) @@ -2810,7 +2704,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) XML_RET_CHECK_AND_GOTO (ret, out); for (k = 0; ; k++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key),"volume%d.xlator%d", i, k); ret = dict_get_str (dict, key, &caps); if (ret) @@ -2833,7 +2726,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) j = 0; for (j = 0; ;j++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.xlator%d.caps%d", i, k, j); ret = dict_get_str (dict, key, &caps); @@ -2868,7 +2760,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) * always */ for (c = COLD_BRICK_COUNT; c < MAX; c++) { - memset (key, 0, sizeof (key)); snprintf (key, 256, keys[c], i); ret = dict_get_int32 (dict, key, &value[c]); if (ret) @@ -2940,7 +2831,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) (local->writer, (xmlChar *)"brick"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.brick%d.uuid", i, index); ret = dict_get_str (dict, key, &uuid); @@ -3051,7 +2941,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) (local->writer, (xmlChar *)"brick"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.brick%d.uuid", i, index); ret = dict_get_str (dict, key, &uuid); @@ -3076,7 +2965,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%s", uuid); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.brick%d.isArbiter", i, index); @@ -3103,7 +2991,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) (local->writer, (xmlChar *)"brick"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.brick%d.uuid", i, j); ret = dict_get_str (dict, key, &uuid); @@ -3114,7 +3001,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) uuid); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.brick%d", i, j); ret = dict_get_str (dict, key, &brick); @@ -3134,7 +3020,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) "%s", uuid); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.brick%d.isArbiter", i, j); if (dict_get (dict, key)) @@ -3157,7 +3042,6 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d", i); ret = cli_xml_output_vol_info_options (local->writer, dict, key); @@ -3311,7 +3195,6 @@ cli_xml_output_peer_hostnames (xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO (ret, out); for (i = 0; i < count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.hostname%d", prefix, i); ret = dict_get_str (dict, key, &hostname); if (ret) @@ -3373,7 +3256,6 @@ cli_xml_output_peer_status (dict_t *dict, int op_ret, int op_errno, ret = xmlTextWriterStartElement (writer, (xmlChar *)"peer"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.uuid", i); ret = dict_get_str (dict, key, &uuid); if (ret) @@ -3384,7 +3266,6 @@ cli_xml_output_peer_status (dict_t *dict, int op_ret, int op_errno, "%s", uuid); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.hostname", i); ret = dict_get_str (dict, key, &hostname); if (ret) @@ -3395,18 +3276,15 @@ cli_xml_output_peer_status (dict_t *dict, int op_ret, int op_errno, "%s", hostname); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.hostname_count", i); ret = dict_get_int32 (dict, key, &hostname_count); if ((ret == 0) && (hostname_count > 0)) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d", i); ret = cli_xml_output_peer_hostnames (writer, dict, key, hostname_count); XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.connected", i); ret = dict_get_int32 (dict, key, &connected); if (ret) @@ -3417,7 +3295,6 @@ cli_xml_output_peer_status (dict_t *dict, int op_ret, int op_errno, "%d", connected); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.stateId", i); ret = dict_get_int32 (dict, key, &state_id); if (!ret) { @@ -3428,7 +3305,6 @@ cli_xml_output_peer_status (dict_t *dict, int op_ret, int op_errno, XML_RET_CHECK_AND_GOTO (ret, out); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.state", i); ret = dict_get_str (dict, key, &state_str); if (!ret) { @@ -3505,7 +3381,6 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, /* Getting status early, to skip nodes that don't have the * rebalance process started */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "status-%d", i); ret = dict_get_int32 (dict, key, &status_rcd); @@ -3520,7 +3395,6 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, ret = xmlTextWriterStartElement (writer, (xmlChar *)"node"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "node-name-%d", i); ret = dict_get_str (dict, key, &node_name); if (ret) @@ -3530,7 +3404,6 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, "%s", node_name); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "node-uuid-%d", i); ret = dict_get_str (dict, key, &node_uuid); if (ret) @@ -3540,7 +3413,6 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, "%s", node_uuid); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "files-%d", i); ret = dict_get_uint64 (dict, key, &files); if (ret) @@ -3551,7 +3423,6 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, files); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "size-%d", i); ret = dict_get_uint64 (dict, key, &size); if (ret) @@ -3562,7 +3433,6 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64,size); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "lookups-%d", i); ret = dict_get_uint64 (dict, key, &lookups); if (ret) @@ -3573,13 +3443,11 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, lookups); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "failures-%d", i); ret = dict_get_uint64 (dict, key, &failures); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "skipped-%d", i); ret = dict_get_uint64 (dict, key, &skipped); @@ -3615,8 +3483,7 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict, cli_vol_task_status_str[status_rcd]); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, 256); - snprintf (key, 256, "run-time-%d", i); + snprintf (key, sizeof (key), "run-time-%d", i); ret = dict_get_double (dict, key, &elapsed); if (ret) goto out; @@ -3741,7 +3608,6 @@ cli_xml_output_vol_tier_status (xmlTextWriterPtr writer, dict_t *dict, ret = xmlTextWriterStartElement (writer, (xmlChar *)"node"); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "node-name-%d", i); ret = dict_get_str (dict, key, &node_name); if (ret) @@ -3751,7 +3617,6 @@ cli_xml_output_vol_tier_status (xmlTextWriterPtr writer, dict_t *dict, "%s", node_name); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "promoted-%d", i); ret = dict_get_uint64 (dict, key, &promoted); if (ret) @@ -3762,7 +3627,6 @@ cli_xml_output_vol_tier_status (xmlTextWriterPtr writer, dict_t *dict, promoted); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "demoted-%d", i); ret = dict_get_uint64 (dict, key, &demoted); if (ret) @@ -3773,8 +3637,7 @@ cli_xml_output_vol_tier_status (xmlTextWriterPtr writer, dict_t *dict, demoted); XML_RET_CHECK_AND_GOTO (ret, out); - memset (key, 0, 256); - snprintf (key, 256, "status-%d", i); + snprintf (key, sizeof (key), "status-%d", i); ret = dict_get_int32 (dict, key, (int32_t *)&status_rcd); status_str = cli_vol_task_status_str[status_rcd]; diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c index 0fd8c098385..176ba6e44de 100644 --- a/heal/src/glfs-heal.c +++ b/heal/src/glfs-heal.c @@ -776,7 +776,6 @@ glfsh_heal_entries (glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc, if ((strcmp (entry->d_name, ".") == 0) || (strcmp (entry->d_name, "..") == 0)) continue; - memset (file, 0, sizeof(file)); snprintf (file, sizeof(file), "gfid:%s", entry->d_name); ret = glfsh_heal_splitbrain_file (fs, top_subvol, rootloc, file, xattr_req); diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c index e002c1fbed9..aeade5b3a20 100644 --- a/libglusterfs/src/client_t.c +++ b/libglusterfs/src/client_t.c @@ -745,7 +745,6 @@ gf_client_dump_fdtables_to_dict (xlator_t *this, dict_t *dict) continue; client = clienttable->cliententries[count].client; if (!strcmp (client->bound_xl->name, this->name)) { - memset(key, 0, sizeof (key)); snprintf (key, sizeof (key), "conn%d", count++); fdtable_dump_to_dict (client->server_ctx. fdtable, @@ -864,7 +863,6 @@ gf_client_dump_inodes_to_dict (xlator_t *this, dict_t *dict) continue; client = clienttable->cliententries[count].client; if (!strcmp (client->bound_xl->name, this->name)) { - memset(key, 0, sizeof (key)); if (client->bound_xl && client->bound_xl-> itable) { /* Presently every brick contains only @@ -880,7 +878,6 @@ gf_client_dump_inodes_to_dict (xlator_t *this, dict_t *dict) continue; prev_bound_xl = client->bound_xl; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "conn%d", count); inode_table_dump_to_dict (client-> diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c index 65b23ed3503..01e292cc107 100644 --- a/libglusterfs/src/fd.c +++ b/libglusterfs/src/fd.c @@ -1164,19 +1164,16 @@ fdentry_dump_to_dict (fdentry_t *fdentry, char *prefix, dict_t *dict, return; if (fdentry->fd) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pid", prefix); ret = dict_set_uint64 (dict, key, fdentry->fd->pid); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.refcount", prefix); ret = dict_set_int32 (dict, key, GF_ATOMIC_GET (fdentry->fd->refcount)); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.flags", prefix); ret = dict_set_int32 (dict, key, fdentry->fd->flags); @@ -1202,19 +1199,16 @@ fdtable_dump_to_dict (fdtable_t *fdtable, char *prefix, dict_t *dict) if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fdtable.refcount", prefix); ret = dict_set_int32 (dict, key, fdtable->refcount); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fdtable.maxfds", prefix); ret = dict_set_uint32 (dict, key, fdtable->max_fds); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fdtable.firstfree", prefix); ret = dict_set_int32 (dict, key, fdtable->first_free); if (ret) @@ -1223,7 +1217,6 @@ fdtable_dump_to_dict (fdtable_t *fdtable, char *prefix, dict_t *dict) for (i = 0; i < fdtable->max_fds; i++) { if (GF_FDENTRY_ALLOCATED == fdtable->fdentries[i].next_free) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fdtable.fdentry%d", prefix, i); fdentry_dump_to_dict (&fdtable->fdentries[i], key, @@ -1231,7 +1224,6 @@ fdtable_dump_to_dict (fdtable_t *fdtable, char *prefix, dict_t *dict) } } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fdtable.openfds", prefix); ret = dict_set_int32 (dict, key, openfds); diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index b8f1539b2f4..488486f35b8 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -2449,25 +2449,21 @@ inode_dump_to_dict (inode_t *inode, char *prefix, dict_t *dict) if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.gfid", prefix); ret = dict_set_dynstr (dict, key, gf_strdup (uuid_utoa (inode->gfid))); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.nlookup", prefix); ret = dict_set_uint64 (dict, key, inode->nlookup); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.ref", prefix); ret = dict_set_uint32 (dict, key, inode->ref); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.ia_type", prefix); ret = dict_set_int32 (dict, key, inode->ia_type); @@ -2488,26 +2484,22 @@ inode_table_dump_to_dict (inode_table_t *itable, char *prefix, dict_t *dict) if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.itable.active_size", prefix); ret = dict_set_uint32 (dict, key, itable->active_size); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.itable.lru_size", prefix); ret = dict_set_uint32 (dict, key, itable->lru_size); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.itable.purge_size", prefix); ret = dict_set_uint32 (dict, key, itable->purge_size); if (ret) goto out; list_for_each_entry (inode, &itable->active, list) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.itable.active%d", prefix, count++); inode_dump_to_dict (inode, key, dict); @@ -2515,7 +2507,6 @@ inode_table_dump_to_dict (inode_table_t *itable, char *prefix, dict_t *dict) count = 0; list_for_each_entry (inode, &itable->lru, list) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.itable.lru%d", prefix, count++); inode_dump_to_dict (inode, key, dict); @@ -2523,7 +2514,6 @@ inode_table_dump_to_dict (inode_table_t *itable, char *prefix, dict_t *dict) count = 0; list_for_each_entry (inode, &itable->purge, list) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.itable.purge%d", prefix, count++); inode_dump_to_dict (inode, key, dict); diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c index 61c779b0453..c4cfebc484a 100644 --- a/libglusterfs/src/stack.c +++ b/libglusterfs/src/stack.c @@ -97,7 +97,6 @@ gf_proc_dump_call_frame (call_frame_t *call_frame, const char *key_buf,...) GF_ASSERT (key_buf); - memset(prefix, 0, sizeof(prefix)); memset(&my_frame, 0, sizeof(my_frame)); va_start(ap, key_buf); vsnprintf(prefix, GF_DUMP_MAX_BUF_LEN, key_buf, ap); @@ -169,7 +168,6 @@ gf_proc_dump_call_stack (call_stack_t *call_stack, const char *key_buf,...) GF_ASSERT (key_buf); - memset(prefix, 0, sizeof(prefix)); va_start(ap, key_buf); vsnprintf(prefix, GF_DUMP_MAX_BUF_LEN, key_buf, ap); va_end(ap); @@ -267,26 +265,22 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame, memcpy (&tmp_frame, call_frame, sizeof (tmp_frame)); UNLOCK (&call_frame->lock); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.refcount", prefix); ret = dict_set_int32 (dict, key, tmp_frame.ref_count); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.translator", prefix); ret = dict_set_dynstr (dict, key, gf_strdup (tmp_frame.this->name)); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.complete", prefix); ret = dict_set_int32 (dict, key, tmp_frame.complete); if (ret) return; if (tmp_frame.root->ctx->measure_latency) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.timings", prefix); snprintf (msg, sizeof (msg), "%ld.%"GF_PRI_SNSECONDS " -> %ld.%"GF_PRI_SNSECONDS, @@ -298,7 +292,6 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame, } if (tmp_frame.parent) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.parent", prefix); ret = dict_set_dynstr (dict, key, gf_strdup (tmp_frame.parent->this->name)); @@ -307,7 +300,6 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame, } if (tmp_frame.wind_from) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.windfrom", prefix); ret = dict_set_dynstr (dict, key, gf_strdup (tmp_frame.wind_from)); @@ -316,7 +308,6 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame, } if (tmp_frame.wind_to) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.windto", prefix); ret = dict_set_dynstr (dict, key, gf_strdup (tmp_frame.wind_to)); @@ -325,7 +316,6 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame, } if (tmp_frame.unwind_from) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.unwindfrom", prefix); ret = dict_set_dynstr (dict, key, gf_strdup (tmp_frame.unwind_from)); @@ -334,7 +324,6 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame, } if (tmp_frame.unwind_to) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.unwind_to", prefix); ret = dict_set_dynstr (dict, key, gf_strdup (tmp_frame.unwind_to)); @@ -357,31 +346,26 @@ gf_proc_dump_call_stack_to_dict (call_stack_t *call_stack, return; count = call_frames_count (call_stack); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.uid", prefix); ret = dict_set_int32 (dict, key, call_stack->uid); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.gid", prefix); ret = dict_set_int32 (dict, key, call_stack->gid); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pid", prefix); ret = dict_set_int32 (dict, key, call_stack->pid); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.unique", prefix); ret = dict_set_uint64 (dict, key, call_stack->unique); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.op", prefix); if (call_stack->type == GF_OP_TYPE_FOP) ret = dict_set_str (dict, key, @@ -392,20 +376,17 @@ gf_proc_dump_call_stack_to_dict (call_stack_t *call_stack, if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.type", prefix); ret = dict_set_int32 (dict, key, call_stack->type); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.count", prefix); ret = dict_set_int32 (dict, key, count); if (ret) return; list_for_each_entry (trav, &call_stack->myframes, frames) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.frame%d", prefix, i); gf_proc_dump_call_frame_to_dict (trav, key, dict); @@ -439,7 +420,6 @@ gf_proc_dump_pending_frames_to_dict (call_pool_t *call_pool, dict_t *dict) goto out; list_for_each_entry (trav, &call_pool->all_frames, all_frames) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "callpool.stack%d", i); gf_proc_dump_call_stack_to_dict (trav, key, dict); i++; diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c index 21a916ea6b8..d769d7a9ef2 100644 --- a/libglusterfs/src/statedump.c +++ b/libglusterfs/src/statedump.c @@ -126,7 +126,6 @@ gf_proc_dump_add_section_fd (char *key, va_list ap) GF_ASSERT(key); - memset (buf, 0, sizeof(buf)); snprintf (buf, GF_DUMP_MAX_BUF_LEN, "\n["); vsnprintf (buf + strlen(buf), GF_DUMP_MAX_BUF_LEN - strlen (buf), key, ap); @@ -175,10 +174,7 @@ gf_proc_dump_write_fd (char *key, char *value, va_list ap) GF_ASSERT (key); - offset = strlen (key); - - memset (buf, 0, GF_DUMP_MAX_BUF_LEN); - snprintf (buf, GF_DUMP_MAX_BUF_LEN, "%s", key); + offset = snprintf (buf, GF_DUMP_MAX_BUF_LEN, "%s", key); snprintf (buf + offset, GF_DUMP_MAX_BUF_LEN - offset, "="); offset += 1; vsnprintf (buf + offset, GF_DUMP_MAX_BUF_LEN - offset, value, ap); @@ -429,49 +425,41 @@ gf_proc_dump_mempool_info_to_dict (glusterfs_ctx_t *ctx, dict_t *dict) return; list_for_each_entry (pool, &ctx->mempool_list, global_list) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "pool%d.name", count); ret = dict_set_str (dict, key, pool->name); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "pool%d.hotcount", count); ret = dict_set_int32 (dict, key, pool->hot_count); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "pool%d.coldcount", count); ret = dict_set_int32 (dict, key, pool->cold_count); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "pool%d.paddedsizeof", count); ret = dict_set_uint64 (dict, key, pool->padded_sizeof_type); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "pool%d.alloccount", count); ret = dict_set_uint64 (dict, key, pool->alloc_count); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "pool%d.max_alloc", count); ret = dict_set_int32 (dict, key, pool->max_alloc); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "pool%d.max-stdalloc", count); ret = dict_set_int32 (dict, key, pool->max_stdalloc); if (ret) return; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "pool%d.pool-misses", count); ret = dict_set_uint64 (dict, key, pool->pool_misses); if (ret) @@ -893,9 +881,7 @@ gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx) //swallow the errors of write for start and end marker ret = sys_write (gf_dump_fd, sign_string, strlen (sign_string)); - memset (sign_string, 0, sizeof (sign_string)); memset (timestr, 0, sizeof (timestr)); - memset (&tv, 0, sizeof (tv)); if (GF_PROC_DUMP_IS_OPTION_ENABLED (mem)) { gf_proc_dump_mem_info (); diff --git a/rpc/rpc-transport/rdma/src/name.c b/rpc/rpc-transport/rdma/src/name.c index f132b9638f8..2db1f08c751 100644 --- a/rpc/rpc-transport/rdma/src/name.c +++ b/rpc/rpc-transport/rdma/src/name.c @@ -411,7 +411,6 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this, listen_host = data_to_str (listen_host_data); } - memset (service, 0, sizeof (service)); sprintf (service, "%d", listen_port); memset (&hints, 0, sizeof (hints)); diff --git a/rpc/rpc-transport/socket/src/name.c b/rpc/rpc-transport/socket/src/name.c index 077736a2e52..34e6372a8f3 100644 --- a/rpc/rpc-transport/socket/src/name.c +++ b/rpc/rpc-transport/socket/src/name.c @@ -409,7 +409,6 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this, } } - memset (service, 0, sizeof (service)); sprintf (service, "%d", listen_port); memset (&hints, 0, sizeof (hints)); diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 1d6564cb962..afec1889071 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -4322,7 +4322,7 @@ fill_layout_info (dht_layout_t *layout, char *buf) char tmp_buf[128] = {0,}; for (i = 0; i < layout->cnt; i++) { - snprintf (tmp_buf, 128, "(%s %u %u)", + snprintf (tmp_buf, sizeof (tmp_buf), "(%s %u %u)", layout->list[i].xlator->name, layout->list[i].start, layout->list[i].stop); diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index 561d1199e10..20f1cccb256 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -631,7 +631,7 @@ dht_filter_loc_subvol_key (xlator_t *this, loc_t *loc, loc_t *new_loc, trav = this->children; while (trav) { - snprintf (key, 1024, "*@%s:%s", this->name, trav->xlator->name); + snprintf (key, sizeof (key), "*@%s:%s", this->name, trav->xlator->name); if (fnmatch (key, loc->name, FNM_NOESCAPE) == 0) { new_name = GF_CALLOC(strlen (loc->name), sizeof (char), diff --git a/xlators/cluster/stripe/src/stripe-helpers.c b/xlators/cluster/stripe/src/stripe-helpers.c index 06568389cc2..18f70fe6d7e 100644 --- a/xlators/cluster/stripe/src/stripe-helpers.c +++ b/xlators/cluster/stripe/src/stripe-helpers.c @@ -261,7 +261,7 @@ stripe_fill_pathinfo_xattr (xlator_t *this, stripe_local_t *local, goto out; } - (void) snprintf (stripe_size_str, 20, "%"PRId64, + (void) snprintf (stripe_size_str, sizeof (stripe_size_str), "%"PRId64, (long long) (local->fctx) ? local->fctx->stripe_size : 0); /* extra bytes for decorations (brackets and <>'s) */ diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index 7eaffa00c78..7a7a9217df0 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -1301,10 +1301,6 @@ io_stats_dump_global_to_logfp (xlator_t *this, struct ios_global_stats *stats, ios_log (this, logfp, "%s", str_read); ios_log (this, logfp, "%s\n", str_write); - memset (str_header, 0, sizeof (str_header)); - memset (str_read, 0, sizeof (str_read)); - memset (str_write, 0, sizeof (str_write)); - snprintf (str_header, sizeof (str_header), "%-12s %c", "Block Size", ':'); snprintf (str_read, sizeof (str_read), "%-12s %c", @@ -1437,7 +1433,6 @@ io_stats_dump_global_to_dict (xlator_t *this, struct ios_global_stats *stats, gf_log (this->name, GF_LOG_ERROR, "failed to set " "interval %d", interval); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-duration", interval); sec = (uint64_t) (now->tv_sec - stats->started_at.tv_sec); ret = dict_set_uint64 (dict, key, sec); @@ -1447,7 +1442,6 @@ io_stats_dump_global_to_dict (xlator_t *this, struct ios_global_stats *stats, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-total-read", interval); ret = dict_set_uint64 (dict, key, GF_ATOMIC_GET (stats->data_read)); if (ret) { @@ -1457,7 +1451,6 @@ io_stats_dump_global_to_dict (xlator_t *this, struct ios_global_stats *stats, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-total-write", interval); ret = dict_set_uint64 (dict, key, GF_ATOMIC_GET (stats->data_written)); if (ret) { @@ -1469,7 +1462,6 @@ io_stats_dump_global_to_dict (xlator_t *this, struct ios_global_stats *stats, for (i = 0; i < 32; i++) { count = GF_ATOMIC_GET (stats->block_count_read[i]); if (count) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%d-read-%d", interval, (1 << i)); ret = dict_set_uint64 (dict, key, count); diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index 8dc20ffc954..b70d32fab77 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -5248,7 +5248,6 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict) } for (i=1; i <= cmd_args_count; i++) { - memset (cmd_arg_name, '\0', sizeof(cmd_arg_name)); snprintf (cmd_arg_name, sizeof(cmd_arg_name), "cmd_arg_%d", i); ret = dict_get_str (dict, cmd_arg_name, &cmd_args[i-1]); @@ -5288,7 +5287,6 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict) output_count = 1; else output_count++; - memset (output_name, '\0', sizeof (output_name)); snprintf (output_name, sizeof (output_name), "output_%d", output_count); if (buf[strlen(buf) - 1] == '\n') diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index d90e82c495c..e37245d14a5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -320,7 +320,7 @@ _build_option_key (dict_t *d, char *k, data_t *v, void *tmp) (strcmp (k, "snap-max-soft-limit") == 0)) return 0; - snprintf (reconfig_key, 256, "volume%d.option.%s", + snprintf (reconfig_key, sizeof (reconfig_key), "volume%d.option.%s", pack->vol_count, k); ret = dict_set_str (pack->dict, reconfig_key, v->data); if (0 == ret) @@ -339,66 +339,56 @@ glusterd_add_tier_volume_detail_to_dict (glusterd_volinfo_t *volinfo, GF_ASSERT (volinfo); GF_ASSERT (dict); - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_type", count); + snprintf (key, sizeof (key), "volume%d.cold_type", count); ret = dict_set_int32 (dict, key, volinfo->tier_info.cold_type); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_brick_count", count); + snprintf (key, sizeof (key), "volume%d.cold_brick_count", count); ret = dict_set_int32 (dict, key, volinfo->tier_info.cold_brick_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_dist_count", count); + snprintf (key, sizeof (key), "volume%d.cold_dist_count", count); ret = dict_set_int32 (dict, key, volinfo->tier_info.cold_dist_leaf_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_replica_count", count); + snprintf (key, sizeof (key), "volume%d.cold_replica_count", count); ret = dict_set_int32 (dict, key, volinfo->tier_info.cold_replica_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_arbiter_count", count); + snprintf (key, sizeof (key), "volume%d.cold_arbiter_count", count); ret = dict_set_int32 (dict, key, volinfo->arbiter_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_disperse_count", count); + snprintf (key, sizeof (key), "volume%d.cold_disperse_count", count); ret = dict_set_int32 (dict, key, volinfo->tier_info.cold_disperse_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.cold_redundancy_count", count); + snprintf (key, sizeof (key), "volume%d.cold_redundancy_count", count); ret = dict_set_int32 (dict, key, volinfo->tier_info.cold_redundancy_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.hot_type", count); + snprintf (key, sizeof (key), "volume%d.hot_type", count); ret = dict_set_int32 (dict, key, volinfo->tier_info.hot_type); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.hot_brick_count", count); + snprintf (key, sizeof (key), "volume%d.hot_brick_count", count); ret = dict_set_int32 (dict, key, volinfo->tier_info.hot_brick_count); if (ret) goto out; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.hot_replica_count", count); + snprintf (key, sizeof (key), "volume%d.hot_replica_count", count); ret = dict_set_int32 (dict, key, volinfo->tier_info.hot_replica_count); if (ret) goto out; @@ -431,8 +421,7 @@ glusterd_add_arbiter_info_to_bricks (glusterd_volinfo_t *volinfo, if ((i - start_index + 1) % volinfo->tier_info.cold_replica_count != 0) continue; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.brick%d.isArbiter", + snprintf (key, sizeof (key), "volume%d.brick%d.isArbiter", count, i); ret = dict_set_int32 (volumes, key, 1); if (ret) @@ -444,8 +433,7 @@ glusterd_add_arbiter_info_to_bricks (glusterd_volinfo_t *volinfo, for (i = 1; i <= volinfo->brick_count; i++) { if (i % volinfo->replica_count != 0) continue; - memset (key, 0, sizeof (key)); - snprintf (key, 256, "volume%d.brick%d.isArbiter", + snprintf (key, sizeof (key), "volume%d.brick%d.isArbiter", count, i); ret = dict_set_int32 (volumes, key, 1); if (ret) @@ -481,27 +469,27 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, GF_ASSERT (priv); - snprintf (key, 256, "volume%d.name", count); + snprintf (key, sizeof (key), "volume%d.name", count); ret = dict_set_str (volumes, key, volinfo->volname); if (ret) goto out; - snprintf (key, 256, "volume%d.type", count); + snprintf (key, sizeof (key), "volume%d.type", count); ret = dict_set_int32 (volumes, key, volinfo->type); if (ret) goto out; - snprintf (key, 256, "volume%d.status", count); + snprintf (key, sizeof (key), "volume%d.status", count); ret = dict_set_int32 (volumes, key, volinfo->status); if (ret) goto out; - snprintf (key, 256, "volume%d.brick_count", count); + snprintf (key, sizeof (key), "volume%d.brick_count", count); ret = dict_set_int32 (volumes, key, volinfo->brick_count); if (ret) goto out; - snprintf (key, 256, "volume%d.hot_brick_count", count); + snprintf (key, sizeof (key), "volume%d.hot_brick_count", count); ret = dict_set_int32 (volumes, key, volinfo->tier_info.hot_brick_count); if (ret) goto out; @@ -513,27 +501,27 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, goto out; } - snprintf (key, 256, "volume%d.dist_count", count); + snprintf (key, sizeof (key), "volume%d.dist_count", count); ret = dict_set_int32 (volumes, key, volinfo->dist_leaf_count); if (ret) goto out; - snprintf (key, 256, "volume%d.stripe_count", count); + snprintf (key, sizeof (key), "volume%d.stripe_count", count); ret = dict_set_int32 (volumes, key, volinfo->stripe_count); if (ret) goto out; - snprintf (key, 256, "volume%d.replica_count", count); + snprintf (key, sizeof (key), "volume%d.replica_count", count); ret = dict_set_int32 (volumes, key, volinfo->replica_count); if (ret) goto out; - snprintf (key, 256, "volume%d.disperse_count", count); + snprintf (key, sizeof (key), "volume%d.disperse_count", count); ret = dict_set_int32 (volumes, key, volinfo->disperse_count); if (ret) goto out; - snprintf (key, 256, "volume%d.redundancy_count", count); + snprintf (key, sizeof (key), "volume%d.redundancy_count", count); ret = dict_set_int32 (volumes, key, volinfo->redundancy_count); if (ret) goto out; @@ -543,7 +531,7 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; - snprintf (key, 256, "volume%d.transport", count); + snprintf (key, sizeof (key), "volume%d.transport", count); ret = dict_set_int32 (volumes, key, volinfo->transport_type); if (ret) goto out; @@ -557,12 +545,12 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; - snprintf (key, 256, "volume%d.rebalance", count); + snprintf (key, sizeof (key), "volume%d.rebalance", count); ret = dict_set_int32 (volumes, key, volinfo->rebal.defrag_cmd); if (ret) goto out; - snprintf (key, 256, "volume%d.snap_count", count); + snprintf (key, sizeof (key), "volume%d.snap_count", count); ret = dict_set_int32 (volumes, key, volinfo->snap_count); if (ret) goto out; @@ -570,7 +558,7 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, #ifdef HAVE_BD_XLATOR if (volinfo->caps) { caps = 0; - snprintf (key, 256, "volume%d.xlator0", count); + snprintf (key, sizeof (key), "volume%d.xlator0", count); buf = GF_MALLOC (256, gf_common_mt_char); if (!buf) { ret = ENOMEM; @@ -585,7 +573,7 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, } if (volinfo->caps & CAPS_THIN) { - snprintf (key, 256, "volume%d.xlator0.caps%d", count, + snprintf (key, sizeof (key), "volume%d.xlator0.caps%d", count, caps++); buf = GF_MALLOC (256, gf_common_mt_char); if (!buf) { @@ -601,7 +589,7 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, } if (volinfo->caps & CAPS_OFFLOAD_COPY) { - snprintf (key, 256, "volume%d.xlator0.caps%d", count, + snprintf (key, sizeof (key), "volume%d.xlator0.caps%d", count, caps++); buf = GF_MALLOC (256, gf_common_mt_char); if (!buf) { @@ -617,7 +605,7 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, } if (volinfo->caps & CAPS_OFFLOAD_SNAPSHOT) { - snprintf (key, 256, "volume%d.xlator0.caps%d", count, + snprintf (key, sizeof (key), "volume%d.xlator0.caps%d", count, caps++); buf = GF_MALLOC (256, gf_common_mt_char); if (!buf) { @@ -633,7 +621,7 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, } if (volinfo->caps & CAPS_OFFLOAD_ZERO) { - snprintf (key, 256, "volume%d.xlator0.caps%d", count, + snprintf (key, sizeof (key), "volume%d.xlator0.caps%d", count, caps++); buf = GF_MALLOC (256, gf_common_mt_char); if (!buf) { @@ -654,8 +642,8 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { char brick[1024] = {0,}; char brick_uuid[64] = {0,}; - snprintf (key, 256, "volume%d.brick%d", count, i); - len = snprintf (brick, 1024, "%s:%s", brickinfo->hostname, + snprintf (key, sizeof (key), "volume%d.brick%d", count, i); + len = snprintf (brick, sizeof (brick), "%s:%s", brickinfo->hostname, brickinfo->path); if ((len < 0) || (len >= 1024)) { ret = -1; @@ -665,8 +653,8 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, ret = dict_set_dynstr (volumes, key, buf); if (ret) goto out; - snprintf (key, 256, "volume%d.brick%d.uuid", count, i); - snprintf (brick_uuid, 64, "%s", uuid_utoa (brickinfo->uuid)); + snprintf (key, sizeof (key), "volume%d.brick%d.uuid", count, i); + snprintf (brick_uuid, sizeof (brick_uuid), "%s", uuid_utoa (brickinfo->uuid)); buf = gf_strdup (brick_uuid); if (!buf) goto out; @@ -676,7 +664,7 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, #ifdef HAVE_BD_XLATOR if (volinfo->caps & CAPS_BD) { - snprintf (key, 256, "volume%d.vg%d", count, i); + snprintf (key, sizeof (key), "volume%d.vg%d", count, i); snprintf (brick, 1024, "%s", brickinfo->vg); buf = gf_strdup (brick); ret = dict_set_dynstr (volumes, key, buf); @@ -702,7 +690,7 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, dict_foreach (dict, _build_option_key, (void *) &pack); dict_foreach (priv->opts, _build_option_key, &pack); - snprintf (key, 256, "volume%d.opt_count", pack.vol_count); + snprintf (key, sizeof (key), "volume%d.opt_count", pack.vol_count); ret = dict_set_int32 (volumes, key, pack.opt_count); out: return ret; @@ -1843,7 +1831,6 @@ __glusterd_handle_cli_list_volume (rpcsvc_request_t *req) goto out; cds_list_for_each_entry (volinfo, &priv->volumes, vol_list) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d", count); ret = dict_set_str (dict, key, volinfo->volname); if (ret) @@ -2773,7 +2760,6 @@ __glusterd_handle_friend_update (rpcsvc_request_t *req) args.mode = GD_MODE_ON; while ( i <= count) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.uuid", i); ret = dict_get_str (dict, key, &uuid_buf); if (ret) @@ -2788,7 +2774,6 @@ __glusterd_handle_friend_update (rpcsvc_request_t *req) continue; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d", i); rcu_read_lock (); @@ -4105,18 +4090,18 @@ unlock: if (flags == GF_CLI_LIST_POOL_NODES) { count++; - snprintf (key, 256, "friend%d.uuid", count); + snprintf (key, sizeof (key), "friend%d.uuid", count); uuid_utoa_r (MY_UUID, my_uuid_str); ret = dict_set_str (friends, key, my_uuid_str); if (ret) goto out; - snprintf (key, 256, "friend%d.hostname", count); + snprintf (key, sizeof (key), "friend%d.hostname", count); ret = dict_set_str (friends, key, "localhost"); if (ret) goto out; - snprintf (key, 256, "friend%d.connected", count); + snprintf (key, sizeof (key), "friend%d.connected", count); ret = dict_set_int32 (friends, key, 1); if (ret) goto out; @@ -5103,7 +5088,7 @@ glusterd_print_gsync_status_by_vol (FILE *fp, glusterd_volinfo_t *volinfo) if (!gsync_rsp_dict) goto out; - ret = gethostname(my_hostname, 256); + ret = gethostname(my_hostname, sizeof (my_hostname)); if (ret) { /* stick to N/A */ (void) strcpy (my_hostname, "N/A"); @@ -5275,7 +5260,6 @@ glusterd_print_client_details (FILE *fp, dict_t *dict, int i; for (i = 1; i <= client_count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.hostname", i-1); ret = dict_get_str (args.dict, key, &clientname); if (ret) { @@ -5285,12 +5269,10 @@ glusterd_print_client_details (FILE *fp, dict_t *dict, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "Client%d.hostname", i); fprintf (fp, "Volume%d.Brick%d.%s: %s\n", volcount, brickcount, key, clientname); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.bytesread", i-1); ret = dict_get_uint64 (args.dict, key, &bytesread); if (ret) { @@ -5300,12 +5282,10 @@ glusterd_print_client_details (FILE *fp, dict_t *dict, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "Client%d.bytesread", i); fprintf (fp, "Volume%d.Brick%d.%s: %"PRIu64"\n", volcount, brickcount, key, bytesread); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.byteswrite", i-1); ret = dict_get_uint64 (args.dict, key, &byteswrite); if (ret) { @@ -5315,12 +5295,10 @@ glusterd_print_client_details (FILE *fp, dict_t *dict, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "Client%d.byteswrite", i); fprintf (fp, "Volume%d.Brick%d.%s: %"PRIu64"\n", volcount, brickcount, key, byteswrite); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.opversion", i-1); ret = dict_get_uint32 (args.dict, key, &opversion); if (ret) { @@ -5330,7 +5308,6 @@ glusterd_print_client_details (FILE *fp, dict_t *dict, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "Client%d.opversion", i); fprintf (fp, "Volume%d.Brick%d.%s: %"PRIu32"\n", volcount, brickcount, key, opversion); diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 63220ffd133..df341c3a3db 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -3442,7 +3442,6 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, } for (i = 1; i <= count; i++) { - memset (brick_key, 0, sizeof (brick_key)); snprintf (brick_key, sizeof (brick_key), "brick%d", i); ret = dict_get_str (volinfo->rebal.dict, brick_key, &brick); @@ -3453,7 +3452,6 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, goto out; } - memset (dict_key, 0, sizeof (dict_key)); len = snprintf (dict_key, sizeof (dict_key), "%s.%s", prefix, brick_key); if ((len < 0) || (len >= sizeof(dict_key))) { @@ -3527,7 +3525,6 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.id", index); if (!uuid_str) @@ -3541,7 +3538,6 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) } uuid_str = NULL; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.status", index); ret = dict_set_int32 (dict, key, status); if (ret) { @@ -4856,7 +4852,6 @@ glusterd_op_volume_dict_uuid_to_hostname (dict_t *dict, const char *key_fmt, GF_ASSERT (key_fmt); for (i = idx_min; i < idx_max; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), key_fmt, i); ret = dict_get_str (dict, key, &uuid_str); if (ret) { @@ -4971,8 +4966,7 @@ glusterd_op_check_peer_defrag_status (dict_t *dict, int count) } do { - memset (key, 0, 256); - snprintf (key, 256, "status-%d", i); + snprintf (key, sizeof (key), "status-%d", i); ret = dict_get_int32 (dict, key, (int32_t *)&status); if (ret) { gf_msg (THIS->name, GF_LOG_WARNING, 0, @@ -5036,13 +5030,11 @@ glusterd_op_modify_port_key (dict_t *op_ctx, int brick_index_max) for (i = 0; i <= brick_index_max; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.rdma_port", i); ret = dict_get_str (op_ctx, key, &port); if (ret) { - memset (old_key, 0, sizeof (old_key)); snprintf (old_key, sizeof (old_key), "brick%d.port", i); ret = dict_get_str (op_ctx, old_key, &port); @@ -5141,7 +5133,6 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) goto out; for (i = 0; i <= brick_index_max; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.rdma_port", i); ret = dict_get_str (op_ctx, key, &port); if (ret) { @@ -5169,11 +5160,9 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) int i; for (i = brick_index_max + 1; i < count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.path", i); ret = dict_get_str (op_ctx, key, &uuid_str); if (!ret) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.peerid", i); uuid = gf_strdup (uuid_str); @@ -5249,11 +5238,9 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) int i; for (i = 1; i <= count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "node-uuid-%d", i); ret = dict_get_str (op_ctx, key, &uuid_str); if (!ret) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "node-name-%d", i); uuid = gf_strdup (uuid_str); diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c index 6652049a27e..6d0cb2131d6 100644 --- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c @@ -590,7 +590,6 @@ gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict, /* Setting the first hostname from the list with this key for backward * compatibility */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.hostname", prefix); address = cds_list_entry (&friend->hostnames, glusterd_peer_hostname_t, hostname_list); @@ -612,7 +611,6 @@ gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict, cds_list_for_each_entry (address, &friend->hostnames, hostname_list) { GF_VALIDATE_OR_GOTO (this->name, (address != NULL), out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.hostname%d", prefix, count); ret = dict_set_dynstr_with_alloc (dict, key, address->hostname); if (ret) { @@ -623,7 +621,6 @@ gd_add_friend_to_dict (glusterd_peerinfo_t *friend, dict_t *dict, } count++; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.address-count", prefix); ret = dict_set_int32 (dict, key, count); if (ret) @@ -771,7 +768,6 @@ gd_update_peerinfo_from_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict, GF_VALIDATE_OR_GOTO (this->name, (dict != NULL), out); GF_VALIDATE_OR_GOTO (this->name, (prefix != NULL), out); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.hostname", prefix); ret = dict_get_str (dict, key, &hostname); if (ret) { @@ -797,7 +793,6 @@ gd_update_peerinfo_from_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.address-count", prefix); ret = dict_get_int32 (dict, key, &count); if (ret) { @@ -808,7 +803,6 @@ gd_update_peerinfo_from_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict, } hostname = NULL; for (i = 0; i < count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.hostname%d",prefix, i); ret = dict_get_str (dict, key, &hostname); if (ret) { @@ -916,7 +910,6 @@ gd_add_peer_hostnames_to_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict, GF_VALIDATE_OR_GOTO (this->name, (prefix != NULL), out); cds_list_for_each_entry (addr, &peerinfo->hostnames, hostname_list) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.hostname%d", prefix, count); ret = dict_set_dynstr_with_alloc (dict, key, addr->hostname); if (ret) @@ -924,7 +917,6 @@ gd_add_peer_hostnames_to_dict (glusterd_peerinfo_t *peerinfo, dict_t *dict, count++; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.hostname_count", prefix); ret = dict_set_int32 (dict, key, count); @@ -950,38 +942,32 @@ gd_add_peer_detail_to_dict (glusterd_peerinfo_t *peerinfo, dict_t *friends, if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.hostname", count); ret = dict_set_str (friends, key, peerinfo->hostname); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.port", count); ret = dict_set_int32 (friends, key, peerinfo->port); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.stateId", count); ret = dict_set_int32 (friends, key, peerinfo->state.state); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.state", count); ret = dict_set_str (friends, key, glusterd_friend_sm_state_name_get(peerinfo->state.state)); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d.connected", count); ret = dict_set_int32 (friends, key, (int32_t)peerinfo->connected); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d", count); ret = gd_add_peer_hostnames_to_dict (peerinfo, friends, key); diff --git a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c index 40dcaa8233c..5e2bd4c9672 100644 --- a/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-quotad-svc.c @@ -132,7 +132,6 @@ glusterd_quotadsvc_start (glusterd_svc_t *svc, int flags) goto out; for (i = 0; options[i]; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "arg%d", i); ret = dict_set_str (cmdline, key, options[i]); if (ret) diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c index cbd1bb0aaea..c048e382970 100644 --- a/xlators/mgmt/glusterd/src/glusterd-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-sm.c @@ -562,7 +562,6 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx) count++; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d", count); ret = gd_add_friend_to_dict (peerinfo, friends, key); if (ret) @@ -666,7 +665,6 @@ glusterd_ac_update_friend (glusterd_friend_sm_event_t *event, void *ctx) count++; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "friend%d", count); ret = gd_add_friend_to_dict (peerinfo, friends, key); if (ret) diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index 1bb1df049f9..d5cb5ea778b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -483,7 +483,6 @@ gd_add_brick_snap_details_to_dict (dict_t *dict, char *prefix, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.device_path", prefix); ret = dict_set_str (dict, key, brickinfo->device_path); if (ret) { @@ -514,7 +513,6 @@ gd_add_brick_snap_details_to_dict (dict_t *dict, char *prefix, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.mount_dir", prefix); ret = dict_set_str (dict, key, brickinfo->mount_dir); if (ret) @@ -567,7 +565,6 @@ gd_add_vol_snap_details_to_dict (dict_t *dict, char *prefix, } if (strlen (volinfo->parent_volname) > 0) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.parent_volname", prefix); ret = dict_set_dynstr_with_alloc (dict, key, volinfo->parent_volname); @@ -579,7 +576,6 @@ gd_add_vol_snap_details_to_dict (dict_t *dict, char *prefix, } } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.is_snap_volume", prefix); ret = dict_set_uint32 (dict, key, volinfo->is_snap_volume); if (ret) { @@ -589,7 +585,6 @@ gd_add_vol_snap_details_to_dict (dict_t *dict, char *prefix, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.snap-max-hard-limit", prefix); ret = dict_set_uint64 (dict, key, volinfo->snap_max_hard_limit); if (ret) { @@ -891,7 +886,6 @@ gd_import_new_brick_snap_details (dict_t *dict, char *prefix, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.device_path", prefix); ret = dict_get_str (dict, key, &snap_device); if (ret) { @@ -919,7 +913,6 @@ gd_import_new_brick_snap_details (dict_t *dict, char *prefix, } gf_strncpy (brickinfo->mnt_opts, mnt_opts, sizeof(brickinfo->mnt_opts)); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.mount_dir", prefix); ret = dict_get_str (dict, key, &mount_dir); if (ret) { @@ -978,7 +971,6 @@ gd_import_volume_snap_details (dict_t *dict, glusterd_volinfo_t *volinfo, } volinfo->is_snap_volume = (is_snap_int != 0); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.restored_from_snap", prefix); ret = dict_get_str (dict, key, &restored_snap); if (ret) { @@ -990,7 +982,6 @@ gd_import_volume_snap_details (dict_t *dict, glusterd_volinfo_t *volinfo, gf_uuid_parse (restored_snap, volinfo->restored_from_snap); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.snap-max-hard-limit", prefix); ret = dict_get_uint64 (dict, key, &volinfo->snap_max_hard_limit); @@ -2228,7 +2219,6 @@ glusterd_add_snapd_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.port", base_key); ret = dict_set_int32 (dict, key, volinfo->snapd.port); if (ret) @@ -2240,13 +2230,11 @@ glusterd_add_snapd_to_dict (glusterd_volinfo_t *volinfo, if (brick_online == _gf_false) pid = -1; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pid", base_key); ret = dict_set_int32 (dict, key, pid); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.status", base_key); ret = dict_set_int32 (dict, key, brick_online); diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index a47b921b3c8..99ec7d3afef 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -1540,7 +1540,6 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src) } for (i = 0; i < volume_count; i++) { - memset (snapbrckcnt, '\0', sizeof(snapbrckcnt)); ret = snprintf (snapbrckcnt, sizeof(snapbrckcnt) - 1, "vol%"PRId64"_brickcount", i+1); ret = dict_get_int64 (src, snapbrckcnt, &brick_count); diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 570ff85df5a..814aa754d97 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -315,7 +315,6 @@ gd_store_brick_snap_details_write (int fd, glusterd_brickinfo_t *brickinfo) } if (strlen(brickinfo->mount_dir) > 0) { - memset (value, 0, sizeof (value)); snprintf (value, sizeof(value), "%s", brickinfo->mount_dir); ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_BRICK_MOUNT_DIR, value); @@ -347,14 +346,12 @@ gd_store_brick_snap_details_write (int fd, glusterd_brickinfo_t *brickinfo) } } - memset (value, 0, sizeof (value)); snprintf (value, sizeof(value), "%d", brickinfo->snap_status); ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_BRICK_SNAP_STATUS, value); if (ret) goto out; - memset (value, 0, sizeof (value)); snprintf (value, sizeof (value), "%lu", brickinfo->statfs_fsid); ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_BRICK_FSID, value); @@ -828,7 +825,6 @@ glusterd_volume_write_snap_details (int fd, glusterd_volinfo_t *volinfo) goto out; } - memset (buf, 0, sizeof (buf)); snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->snap_max_hard_limit); ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT, buf); @@ -4931,7 +4927,6 @@ glusterd_store_save_quota_version_and_cksum (glusterd_volinfo_t *volinfo) goto out; } - memset (buf, 0, sizeof (buf)); snprintf (buf, sizeof (buf)-1, "%u", volinfo->quota_conf_version); ret = gf_store_save_value (fd, "version", buf); if (ret) { diff --git a/xlators/mgmt/glusterd/src/glusterd-tier.c b/xlators/mgmt/glusterd/src/glusterd-tier.c index 0823a83449d..608b035fa16 100644 --- a/xlators/mgmt/glusterd/src/glusterd-tier.c +++ b/xlators/mgmt/glusterd/src/glusterd-tier.c @@ -1138,7 +1138,6 @@ glusterd_add_tierd_to_dict (glusterd_volinfo_t *volinfo, * an zero value to parse. * */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.port", base_key); ret = dict_set_int32 (dict, key, 0); if (ret) @@ -1148,13 +1147,11 @@ glusterd_add_tierd_to_dict (glusterd_volinfo_t *volinfo, brick_online = gf_is_service_running (pidfile, &pid); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pid", base_key); ret = dict_set_int32 (dict, key, pid); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.status", base_key); ret = dict_set_int32 (dict, key, brick_online); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 352e445e28b..5afeebac78b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -2951,79 +2951,66 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.type", prefix, count); ret = dict_set_int32 (dict, key, volinfo->type); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick_count", prefix, count); ret = dict_set_int32 (dict, key, volinfo->brick_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.version", prefix, count); ret = dict_set_int32 (dict, key, volinfo->version); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.status", prefix, count); ret = dict_set_int32 (dict, key, volinfo->status); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.sub_count", prefix, count); ret = dict_set_int32 (dict, key, volinfo->sub_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.stripe_count", prefix, count); ret = dict_set_int32 (dict, key, volinfo->stripe_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.replica_count", prefix, count); ret = dict_set_int32 (dict, key, volinfo->replica_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.arbiter_count", prefix, count); ret = dict_set_int32 (dict, key, volinfo->arbiter_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.disperse_count", prefix, count); ret = dict_set_int32 (dict, key, volinfo->disperse_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.redundancy_count", prefix, count); ret = dict_set_int32 (dict, key, volinfo->redundancy_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.dist_count", prefix, count); ret = dict_set_int32 (dict, key, volinfo->dist_leaf_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.ckusm", prefix, count); ret = dict_set_int64 (dict, key, volinfo->cksum); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.transport_type", prefix, count); ret = dict_set_uint32 (dict, key, volinfo->transport_type); if (ret) @@ -3031,33 +3018,28 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, /* tiering related variables */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_brick_count", prefix, count); ret = dict_set_uint32 (dict, key, volinfo->tier_info.cold_brick_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_type", prefix, count); ret = dict_set_uint32 (dict, key, volinfo->tier_info.cold_type); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_replica_count", prefix, count); ret = dict_set_uint32 (dict, key, volinfo->tier_info.cold_replica_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_disperse_count", prefix, count); ret = dict_set_uint32 (dict, key, volinfo->tier_info.cold_disperse_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_redundancy_count", prefix, count); ret = dict_set_uint32 (dict, key, @@ -3065,33 +3047,28 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_dist_count", prefix, count); ret = dict_set_uint32 (dict, key, volinfo->tier_info.cold_dist_leaf_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.hot_brick_count", prefix, count); ret = dict_set_uint32 (dict, key, volinfo->tier_info.hot_brick_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.hot_type", prefix, count); ret = dict_set_uint32 (dict, key, volinfo->tier_info.hot_type); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.hot_replica_count", prefix, count); ret = dict_set_uint32 (dict, key, volinfo->tier_info.hot_replica_count); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d", prefix, count); ret = gd_add_vol_snap_details_to_dict (dict, key, volinfo); if (ret) @@ -3102,14 +3079,12 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, ret = -1; goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.volume_id", prefix, count); ret = dict_set_dynstr (dict, key, volume_id_str); if (ret) goto out; volume_id_str = NULL; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.username", prefix, count); str = glusterd_auth_get_username (volinfo); if (str) { @@ -3118,7 +3093,6 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.password", prefix, count); str = glusterd_auth_get_password (volinfo); if (str) { @@ -3127,7 +3101,6 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, 256, "%s%d.rebalance", prefix, count); ret = dict_set_int32 (dict, key, volinfo->rebal.defrag_cmd); if (ret) @@ -3139,14 +3112,12 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, ret = -1; goto out; } - memset (key, 0, sizeof (key)); snprintf (key, 256, "%s%d.rebalance-id", prefix, count); ret = dict_set_dynstr (dict, key, rebalance_id_str); if (ret) goto out; rebalance_id_str = NULL; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.rebalance-op", prefix, count); ret = dict_set_uint32 (dict, key, volinfo->rebal.op); if (ret) @@ -3162,7 +3133,6 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, dict_foreach (volinfo->rebal.dict, _add_dict_to_prdict, &ctx); ctx.opt_count--; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.rebal-dict-count", count); ret = dict_set_int32 (dict, key, ctx.opt_count); if (ret) @@ -3179,7 +3149,6 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, dict_foreach (volinfo->dict, _add_dict_to_prdict, &ctx); ctx.opt_count--; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.opt-count", prefix, count); ret = dict_set_int32 (dict, key, ctx.opt_count); if (ret) @@ -3195,42 +3164,36 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, dict_foreach (volinfo->gsync_slaves, _add_dict_to_prdict, &ctx); ctx.opt_count--; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.gsync-count", prefix, count); ret = dict_set_int32 (dict, key, ctx.opt_count); if (ret) goto out; cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d.hostname", prefix, count, i); ret = dict_set_str (dict, key, brickinfo->hostname); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d.path", prefix, count, i); ret = dict_set_str (dict, key, brickinfo->path); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d.decommissioned", prefix, count, i); ret = dict_set_int32 (dict, key, brickinfo->decommissioned); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d.brick_id", prefix, count, i); ret = dict_set_str (dict, key, brickinfo->brick_id); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d.uuid", prefix, count, i); ret = dict_set_dynstr_with_alloc (dict, key, @@ -3238,7 +3201,6 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d", prefix, count, i); ret = gd_add_brick_snap_details_to_dict (dict, key, brickinfo); if (ret) @@ -3250,23 +3212,19 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, /* Add volume op-versions to dict. This prevents volume inconsistencies * in the cluster */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.op-version", prefix, count); ret = dict_set_int32 (dict, key, volinfo->op_version); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.client-op-version", prefix, count); ret = dict_set_int32 (dict, key, volinfo->client_op_version); if (ret) goto out; /*Add volume Capability (BD Xlator) to dict*/ - memset (key, 0 ,sizeof (key)); snprintf (key, sizeof (key), "%s%d.caps", prefix, count); ret = dict_set_int32 (dict, key, volinfo->caps); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.quota-xattr-version", prefix, count); ret = dict_set_int32 (dict, key, volinfo->quota_xattr_version); out: @@ -3454,7 +3412,6 @@ glusterd_compare_friend_volume (dict_t *peer_data, int32_t count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.version", count); ret = dict_get_int32 (peer_data, key, &version); if (ret) @@ -3476,7 +3433,6 @@ glusterd_compare_friend_volume (dict_t *peer_data, int32_t count, //Now, versions are same, compare cksums. // - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.ckusm", count); ret = dict_get_uint32 (peer_data, key, &cksum); if (ret) @@ -3492,7 +3448,6 @@ glusterd_compare_friend_volume (dict_t *peer_data, int32_t count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.quota-version", count); ret = dict_get_uint32 (peer_data, key, "a_version); if (ret) { @@ -3521,7 +3476,6 @@ glusterd_compare_friend_volume (dict_t *peer_data, int32_t count, //Now, versions are same, compare cksums. // - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.quota-cksum", count); ret = dict_get_uint32 (peer_data, key, "a_cksum); if (ret) { @@ -3545,7 +3499,6 @@ glusterd_compare_friend_volume (dict_t *peer_data, int32_t count, *status = GLUSTERD_VOL_COMP_SCS; out: - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.update", count); if (*status == GLUSTERD_VOL_COMP_UPDATE_REQ) { @@ -3575,7 +3528,6 @@ import_prdict_dict (dict_t *peer_data, dict_t *dst_dict, char *key_prefix, char msg[2048] = {0}; while (i <= opt_count) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.%s%d", prefix, key_prefix, i); ret = dict_get_str (peer_data, key, &opt_key); @@ -3585,7 +3537,6 @@ import_prdict_dict (dict_t *peer_data, dict_t *dst_dict, char *key_prefix, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.%s%d", prefix, value_prefix, i); ret = dict_get_str (peer_data, key, &opt_val); @@ -3649,7 +3600,6 @@ glusterd_import_friend_volume_opts (dict_t *peer_data, int count, GF_ASSERT (peer_data); GF_ASSERT (volinfo); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.opt-count", prefix, count); ret = dict_get_int32 (peer_data, key, &opt_count); if (ret) { @@ -3667,7 +3617,6 @@ glusterd_import_friend_volume_opts (dict_t *peer_data, int count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.gsync-count", prefix, count); ret = dict_get_int32 (peer_data, key, &opt_count); if (ret) { @@ -3717,7 +3666,6 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count, GF_ASSERT (brickinfo); GF_ASSERT (prefix); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d.hostname", prefix, vol_count, brick_count); ret = dict_get_str (peer_data, key, &hostname); @@ -3726,7 +3674,6 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d.path", prefix, vol_count, brick_count); ret = dict_get_str (peer_data, key, &path); @@ -3735,12 +3682,10 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d.brick_id", prefix, vol_count, brick_count); ret = dict_get_str (peer_data, key, &brick_id); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d.decommissioned", prefix, vol_count, brick_count); ret = dict_get_int32 (peer_data, key, &decommissioned); @@ -3760,14 +3705,12 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count, if (brick_id) strcpy (new_brickinfo->brick_id, brick_id); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d", prefix, vol_count, brick_count); ret = gd_import_new_brick_snap_details (peer_data, key, new_brickinfo); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d.uuid", prefix, vol_count, brick_count); ret = dict_get_str (peer_data, key, &brick_uuid_str); @@ -3962,7 +3905,6 @@ gd_import_friend_volume_rebal_dict (dict_t *dict, int count, GF_ASSERT (dict); GF_ASSERT (volinfo); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.rebal-dict-count", count); ret = dict_get_int32 (dict, key, &dict_count); if (ret) { @@ -4025,7 +3967,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, strncpy (new_volinfo->volname, volname, sizeof(new_volinfo->volname) - 1); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.type", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->type); if (ret) { @@ -4040,7 +3981,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, strncpy (new_volinfo->parent_volname, parent_volname, sizeof(new_volinfo->parent_volname)-1); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->brick_count); if (ret) { @@ -4049,7 +3989,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.version", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->version); if (ret) { @@ -4058,7 +3997,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.status", prefix, count); ret = dict_get_int32 (peer_data, key, (int32_t *)&new_volinfo->status); if (ret) { @@ -4067,7 +4005,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.sub_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->sub_count); if (ret) { @@ -4078,7 +4015,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'stripe_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.stripe_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->stripe_count); if (ret) @@ -4088,7 +4024,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'replica_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.replica_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->replica_count); if (ret) @@ -4098,7 +4033,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'arbiter_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.arbiter_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->arbiter_count); if (ret) @@ -4108,7 +4042,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'disperse_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.disperse_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->disperse_count); if (ret) @@ -4118,7 +4051,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'redundancy_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.redundancy_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->redundancy_count); if (ret) @@ -4128,7 +4060,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'dist_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.dist_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->dist_leaf_count); if (ret) @@ -4138,7 +4069,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'hot_brick_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.hot_brick_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->tier_info.hot_brick_count); @@ -4148,7 +4078,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'hot_type' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.hot_type", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->tier_info.hot_type); @@ -4158,7 +4087,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'hot_replica_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.hot_replica_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->tier_info.hot_replica_count); @@ -4168,7 +4096,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'cold_brick_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_brick_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->tier_info.cold_brick_count); @@ -4178,7 +4105,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'cold_type' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_type", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->tier_info.cold_type); @@ -4188,7 +4114,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'cold_replica_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_replica_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->tier_info.cold_replica_count); @@ -4198,7 +4123,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'cold_disperse_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_disperse_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->tier_info.cold_disperse_count); @@ -4208,7 +4132,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'cold_redundancy_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_redundancy_count", prefix, count); ret = dict_get_int32 (peer_data, key, @@ -4219,7 +4142,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, /* not having a 'cold_dist_count' key is not a error (as peer may be of old version) */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.cold_dist_count", prefix, count); ret = dict_get_int32 (peer_data, key, &new_volinfo->tier_info.cold_dist_leaf_count); @@ -4229,7 +4151,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, new_volinfo->subvol_count = new_volinfo->brick_count/ glusterd_get_dist_leaf_count (new_volinfo); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.ckusm", prefix, count); ret = dict_get_uint32 (peer_data, key, &new_volinfo->cksum); if (ret) { @@ -4238,7 +4159,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.volume_id", prefix, count); ret = dict_get_str (peer_data, key, &volume_id_str); if (ret) { @@ -4249,7 +4169,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, gf_uuid_parse (volume_id_str, new_volinfo->volume_id); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.username", prefix, count); ret = dict_get_str (peer_data, key, &str); if (!ret) { @@ -4258,7 +4177,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.password", prefix, count); ret = dict_get_str (peer_data, key, &str); if (!ret) { @@ -4267,7 +4185,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.transport_type", prefix, count); ret = dict_get_uint32 (peer_data, key, &new_volinfo->transport_type); if (ret) { @@ -4276,7 +4193,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.rebalance", prefix, count); ret = dict_get_uint32 (peer_data, key, &new_volinfo->rebal.defrag_cmd); if (ret) { @@ -4285,7 +4201,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.rebalance-id", prefix, count); ret = dict_get_str (peer_data, key, &rebalance_id_str); if (ret) { @@ -4297,7 +4212,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, gf_uuid_parse (rebalance_id_str, new_volinfo->rebal.rebalance_id); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.rebalance-op", prefix, count); ret = dict_get_uint32 (peer_data, key, (uint32_t *) &new_volinfo->rebal.op); @@ -4315,7 +4229,6 @@ glusterd_import_volinfo (dict_t *peer_data, int count, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d", prefix, count); ret = gd_import_volume_snap_details (peer_data, new_volinfo, key, volname); @@ -4340,12 +4253,10 @@ glusterd_import_volinfo (dict_t *peer_data, int count, * Either both the volume op-versions should be absent or both should be * present. Only one being present is a failure */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.op-version", prefix, count); ret = dict_get_int32 (peer_data, key, &op_version); if (ret) ret = 0; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.client-op-version", prefix, count); ret = dict_get_int32 (peer_data, key, &client_op_version); if (ret) @@ -4366,12 +4277,10 @@ glusterd_import_volinfo (dict_t *peer_data, int count, new_volinfo->client_op_version = 1; } - memset (key, 0 ,sizeof (key)); snprintf (key, sizeof (key), "%s%d.caps", prefix, count); /*This is not present in older glusterfs versions, so ignore ret value*/ ret = dict_get_int32 (peer_data, key, &new_volinfo->caps); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.quota-xattr-version", prefix, count); /*This is not present in older glusterfs versions, so ignore ret value*/ ret = dict_get_int32 (peer_data, key, @@ -4682,7 +4591,6 @@ glusterd_import_friend_volume (dict_t *peer_data, int count) priv = this->private; GF_ASSERT (priv); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "volume%d.update", count); ret = dict_get_int32 (peer_data, key, &update); if (ret || !update) { @@ -5275,13 +5183,11 @@ glusterd_add_node_to_dict (char *server, dict_t *dict, int count, if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.path", count); ret = dict_set_dynstr (dict, key, gf_strdup (uuid_utoa (MY_UUID))); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.port", count); /* Port is available only for the NFS server. * Self-heal daemon doesn't provide any port for access @@ -5299,13 +5205,11 @@ glusterd_add_node_to_dict (char *server, dict_t *dict, int count, if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.pid", count); ret = dict_set_int32 (dict, key, pid); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.status", count); ret = dict_set_int32 (dict, key, running); if (ret) @@ -6116,29 +6020,24 @@ search_brick_path_from_proc (pid_t brick_pid, char *brickpath) size_t len = 0; int fd = -1; char path[PATH_MAX] = {0,}; - char sym[PATH_MAX] = {0,}; struct dirent scratch[2] = {{0,},}; char *brick_path = NULL; if (!brickpath) goto out; - sprintf(path, "/proc/%d/fd/", brick_pid); - dirp = sys_opendir (path); - if (!dirp) + len = sprintf(path, "/proc/%d/fd/", brick_pid); + if (len >= (sizeof(path) - 2)) goto out; - len = strlen (path); - if (len >= (sizeof(path) - 2)) + dirp = sys_opendir (path); + if (!dirp) goto out; fd = dirfd (dirp); if (fd < 0) goto out; - memset(path, 0, sizeof(path)); - memset(sym, 0, sizeof(sym)); - while ((dp = sys_readdir(dirp, scratch))) { if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) @@ -6148,14 +6047,14 @@ search_brick_path_from_proc (pid_t brick_pid, char *brickpath) if (!strtol(dp->d_name, (char **)NULL, 10)) continue; - len = readlinkat (fd, dp->d_name, sym, sizeof(sym) - 1); + len = readlinkat (fd, dp->d_name, path, sizeof(path) - 1); + /* TODO: handle len == -1 -> error condition in readlinkat */ if (len > 1) { - sym[len] = '\0'; - if (!strcmp (sym, brickpath)) { - brick_path = gf_strdup(sym); + path[len] = '\0'; + if (!strcmp (path, brickpath)) { + brick_path = gf_strdup(path); break; } - memset (sym, 0, sizeof (sym)); } } out: @@ -6979,7 +6878,6 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count) struct fs_info *fs = NULL; static dict_t *cached_fs = NULL; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.device", count); ret = dict_get_str (dict, key, &device); if (ret) @@ -6993,7 +6891,6 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count) cached_fs = dict_new (); } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.fs_name", count); ret = dict_get_str (dict, key, &fs_name); if (ret) @@ -7087,7 +6984,6 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count) } cached: - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.inode_size", count); ret = dict_set_dynstr_with_alloc (dict, key, cur_word); @@ -7159,7 +7055,6 @@ glusterd_add_brick_mount_details (glusterd_brickinfo_t *brickinfo, } /* get device file */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.device", base_key); ret = dict_set_dynstr_with_alloc (dict, key, entry->mnt_fsname); @@ -7167,7 +7062,6 @@ glusterd_add_brick_mount_details (glusterd_brickinfo_t *brickinfo, goto out; /* fs type */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.fs_name", base_key); ret = dict_set_dynstr_with_alloc (dict, key, entry->mnt_type); @@ -7175,7 +7069,6 @@ glusterd_add_brick_mount_details (glusterd_brickinfo_t *brickinfo, goto out; /* mount options */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.mnt_options", base_key); ret = dict_set_dynstr_with_alloc (dict, key, entry->mnt_opts); @@ -7264,7 +7157,6 @@ glusterd_add_brick_detail_to_dict (glusterd_volinfo_t *volinfo, /* file system block size */ block_size = brickstat.f_bsize; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.block_size", base_key); ret = dict_set_uint64 (dict, key, block_size); if (ret) @@ -7272,7 +7164,6 @@ glusterd_add_brick_detail_to_dict (glusterd_volinfo_t *volinfo, /* free space in brick */ memfree = brickstat.f_bfree * brickstat.f_bsize; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.free", base_key); ret = dict_set_uint64 (dict, key, memfree); if (ret) @@ -7280,7 +7171,6 @@ glusterd_add_brick_detail_to_dict (glusterd_volinfo_t *volinfo, /* total space of brick */ memtotal = brickstat.f_blocks * brickstat.f_bsize; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.total", base_key); ret = dict_set_uint64 (dict, key, memtotal); if (ret) @@ -7289,7 +7179,6 @@ glusterd_add_brick_detail_to_dict (glusterd_volinfo_t *volinfo, /* inodes: total and free counts only for ext2/3/4 and xfs */ inodes_total = brickstat.f_files; if (inodes_total) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.total_inodes", base_key); ret = dict_set_uint64 (dict, key, inodes_total); if (ret) @@ -7298,7 +7187,6 @@ glusterd_add_brick_detail_to_dict (glusterd_volinfo_t *volinfo, inodes_free = brickstat.f_ffree; if (inodes_free) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.free_inodes", base_key); ret = dict_set_uint64 (dict, key, inodes_free); if (ret) @@ -7349,14 +7237,12 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.path", base_key); ret = dict_set_str (dict, key, brickinfo->path); if (ret) goto out; /* add peer uuid */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.peerid", base_key); ret = dict_set_dynstr_with_alloc (dict, key, uuid_utoa (brickinfo->uuid)); @@ -7364,14 +7250,12 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.port", base_key); ret = dict_set_int32 (dict, key, (volinfo->transport_type == GF_TRANSPORT_RDMA) ? 0 : brickinfo->port); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.rdma_port", base_key); if (volinfo->transport_type == GF_TRANSPORT_RDMA) { ret = dict_set_int32 (dict, key, brickinfo->port); @@ -7407,13 +7291,11 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo, } } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pid", base_key); ret = dict_set_int32 (dict, key, pid); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.status", base_key); ret = dict_set_int32 (dict, key, brick_online); @@ -7437,7 +7319,6 @@ glusterd_get_all_volnames (dict_t *dict) GF_ASSERT (priv); cds_list_for_each_entry (entry, &priv->volumes, vol_list) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "vol%d", vol_count); ret = dict_set_str (dict, key, entry->volname); if (ret) @@ -7868,21 +7749,18 @@ glusterd_sm_tr_log_transition_add_to_dict (dict_t *dict, GF_ASSERT (dict); GF_ASSERT (log); - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "log%d-old-state", count); str = log->state_name_get (log->transitions[i].old_state); ret = dict_set_str (dict, key, str); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "log%d-event", count); str = log->event_name_get (log->transitions[i].event); ret = dict_set_str (dict, key, str); if (ret) goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "log%d-new-state", count); str = log->state_name_get (log->transitions[i].new_state); ret = dict_set_str (dict, key, str); @@ -7890,7 +7768,6 @@ glusterd_sm_tr_log_transition_add_to_dict (dict_t *dict, goto out; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "log%d-time", count); gf_time_fmt (timestr, sizeof timestr, log->transitions[i].time, gf_timefmt_FT); @@ -7935,7 +7812,6 @@ glusterd_sm_tr_log_add_to_dict (dict_t *dict, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "count"); ret = dict_set_int32 (dict, key, log->count); @@ -9745,7 +9621,6 @@ glusterd_append_status_dicts (dict_t *dst, dict_t *src) } for (i = 0; i < src_count; i++) { - memset (sts_val_name, '\0', sizeof(sts_val_name)); snprintf (sts_val_name, sizeof(sts_val_name), "status_value%d", i); ret = dict_get_bin (src, sts_val_name, (void **) &sts_val); @@ -9762,7 +9637,6 @@ glusterd_append_status_dicts (dict_t *dst, dict_t *src) memcpy (dst_sts_val, sts_val, sizeof(gf_gsync_status_t)); - memset (sts_val_name, '\0', sizeof(sts_val_name)); snprintf (sts_val_name, sizeof(sts_val_name), "status_value%d", i + dst_count); ret = dict_set_bin (dst, sts_val_name, dst_sts_val, sizeof(gf_gsync_status_t)); @@ -10170,7 +10044,6 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, */ for (i = 0; i < remote_count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.type", i); ret = dict_get_str (rsp_dict, key, &task_type); if (ret) { @@ -10189,7 +10062,6 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, if (!strcmp (task_type, "Replace brick")) continue; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.status", i); ret = dict_get_int32 (rsp_dict, key, &remote_status); if (ret) { @@ -10207,7 +10079,6 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, goto out; } for (j = 0; j < local_count; j++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.id", j); ret = dict_get_str (ctx_dict, key, &local_task_id); if (ret) { @@ -10231,7 +10102,6 @@ glusterd_volume_status_aggregate_tasks_status (dict_t *ctx_dict, continue; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "task%d.status", j); ret = dict_get_int32 (ctx_dict, key, &local_status); if (ret) { @@ -10331,7 +10201,6 @@ glusterd_volume_status_copy_to_op_ctx_dict (dict_t *aggr, dict_t *rsp_dict) goto out; for (i = 0; i < vol_count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "vol%d", i); ret = dict_get_str (rsp_dict, key, &volname); if (ret) @@ -10575,7 +10444,6 @@ glusterd_volume_bitrot_scrub_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) ret = dict_get_str (rsp_dict, key, &node_uuid); if (!ret) { node_uuid_str = gf_strdup (node_uuid); - memset (key, 0, 256); snprintf (key, 256, "node-uuid-%d", src_count+dst_count); ret = dict_set_dynstr (aggr, key, node_uuid_str); if (ret) { @@ -10583,11 +10451,9 @@ glusterd_volume_bitrot_scrub_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "scrub-running-%d", src_count); ret = dict_get_int8 (rsp_dict, key, &scrub_running); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "scrub-running-%d", src_count+dst_count); ret = dict_set_int8 (aggr, key, scrub_running); if (ret) { @@ -10596,11 +10462,9 @@ glusterd_volume_bitrot_scrub_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "scrubbed-files-%d", src_count); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "scrubbed-files-%d", src_count+dst_count); ret = dict_set_uint64 (aggr, key, value); if (ret) { @@ -10609,11 +10473,9 @@ glusterd_volume_bitrot_scrub_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "unsigned-files-%d", src_count); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "unsigned-files-%d", src_count+dst_count); ret = dict_set_uint64 (aggr, key, value); if (ret) { @@ -10622,12 +10484,10 @@ glusterd_volume_bitrot_scrub_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "last-scrub-time-%d", src_count); ret = dict_get_str (rsp_dict, key, &last_scrub_time); if (!ret) { scrub_time = gf_strdup (last_scrub_time); - memset (key, 0, 256); snprintf (key, 256, "last-scrub-time-%d", src_count+dst_count); ret = dict_set_dynstr (aggr, key, scrub_time); if (ret) { @@ -10636,11 +10496,9 @@ glusterd_volume_bitrot_scrub_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "scrub-duration-%d", src_count); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "scrub-duration-%d", src_count+dst_count); ret = dict_set_uint64 (aggr, key, value); if (ret) { @@ -10649,11 +10507,9 @@ glusterd_volume_bitrot_scrub_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "error-count-%d", src_count); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "error-count-%d", src_count+dst_count); ret = dict_set_uint64 (aggr, key, value); if (ret) { @@ -10663,11 +10519,9 @@ glusterd_volume_bitrot_scrub_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) /* Storing all the bad files in the dictionary */ for (j = 0; j < value; j++) { - memset (key, 0, 256); snprintf (key, 256, "quarantine-%d-%d", j, src_count); ret = dict_get_str (rsp_dict, key, &bad_gfid_str); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "quarantine-%d-%d", j, src_count+dst_count); ret = dict_set_dynstr_with_alloc (aggr, key, @@ -10872,7 +10726,6 @@ glusterd_bitrot_volume_node_rsp (dict_t *aggr, dict_t *rsp_dict) ret = dict_get_int8 (rsp_dict, "scrub-running", &scrub_running); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "scrub-running-%d", i); ret = dict_set_uint64 (aggr, key, scrub_running); if (ret) { @@ -10883,7 +10736,6 @@ glusterd_bitrot_volume_node_rsp (dict_t *aggr, dict_t *rsp_dict) ret = dict_get_uint64 (rsp_dict, "scrubbed-files", &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "scrubbed-files-%d", i); ret = dict_set_uint64 (aggr, key, value); if (ret) { @@ -10894,7 +10746,6 @@ glusterd_bitrot_volume_node_rsp (dict_t *aggr, dict_t *rsp_dict) ret = dict_get_uint64 (rsp_dict, "unsigned-files", &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "unsigned-files-%d", i); ret = dict_set_uint64 (aggr, key, value); if (ret) { @@ -10905,7 +10756,6 @@ glusterd_bitrot_volume_node_rsp (dict_t *aggr, dict_t *rsp_dict) ret = dict_get_str (rsp_dict, "last-scrub-time", &last_scrub_time); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "last-scrub-time-%d", i); scrub_time = gf_strdup (last_scrub_time); @@ -10918,7 +10768,6 @@ glusterd_bitrot_volume_node_rsp (dict_t *aggr, dict_t *rsp_dict) ret = dict_get_uint64 (rsp_dict, "scrub-duration", &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "scrub-duration-%d", i); ret = dict_set_uint64 (aggr, key, value); if (ret) { @@ -10929,7 +10778,6 @@ glusterd_bitrot_volume_node_rsp (dict_t *aggr, dict_t *rsp_dict) ret = dict_get_uint64 (rsp_dict, "total-count", &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "error-count-%d", i); ret = dict_set_uint64 (aggr, key, value); if (ret) { @@ -10939,11 +10787,9 @@ glusterd_bitrot_volume_node_rsp (dict_t *aggr, dict_t *rsp_dict) /* Storing all the bad files in the dictionary */ for (j = 0; j < value; j++) { - memset (key, 0, 256); snprintf (key, 256, "quarantine-%d", j); ret = dict_get_str (rsp_dict, key, &bad_gfid_str); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "quarantine-%d-%d", j, i); ret = dict_set_dynstr_with_alloc (aggr, key, bad_gfid_str); @@ -11016,7 +10862,6 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) GD_MSG_DICT_GET_FAILED, "failed to get index"); - memset (key, 0, 256); snprintf (key, 256, "node-uuid-%d", index); ret = dict_get_str (rsp_dict, key, &node_uuid); if (!ret) { @@ -11045,7 +10890,6 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } /* Setting the same index for the node, as is in the peerlist.*/ - memset (key, 0, 256); snprintf (key, 256, "node-uuid-%d", current_index); ret = dict_set_dynstr (ctx_dict, key, node_uuid_str); if (ret) { @@ -11057,7 +10901,6 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) snprintf (key, 256, "files-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "files-%d", current_index); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11066,11 +10909,9 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "size-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "size-%d", current_index); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11079,11 +10920,9 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "lookups-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "lookups-%d", current_index); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11092,11 +10931,9 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "status-%d", index); ret = dict_get_int32 (rsp_dict, key, &value32); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "status-%d", current_index); ret = dict_set_int32 (ctx_dict, key, value32); if (ret) { @@ -11105,11 +10942,9 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "failures-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "failures-%d", current_index); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11118,11 +10953,9 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "skipped-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "skipped-%d", current_index); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11130,11 +10963,9 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) "failed to set skipped count"); } } - memset (key, 0, 256); snprintf (key, 256, "run-time-%d", index); ret = dict_get_double (rsp_dict, key, &elapsed_time); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "run-time-%d", current_index); ret = dict_set_double (ctx_dict, key, elapsed_time); if (ret) { @@ -11143,11 +10974,9 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "time-left-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "time-left-%d", current_index); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11155,11 +10984,9 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) "failed to set time-left"); } } - memset (key, 0, 256); snprintf (key, 256, "demoted-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "demoted-%d", current_index); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11167,11 +10994,9 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) "failed to set demoted count"); } } - memset (key, 0, 256); snprintf (key, 256, "promoted-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "promoted-%d", current_index); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11237,7 +11062,6 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) GD_MSG_DICT_GET_FAILED, "failed to get index"); - memset (key, 0, 256); snprintf (key, 256, "node-uuid-%d", index); ret = dict_get_str (rsp_dict, key, &node_uuid); if (!ret) { @@ -11252,7 +11076,6 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) GD_MSG_DICT_SET_FAILED, "Failed to set count"); - memset (key, 0, 256); snprintf (key, 256, "node-uuid-%d", count); ret = dict_set_dynstr (ctx_dict, key, node_uuid_str); if (ret) { @@ -11263,7 +11086,6 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) snprintf (key, 256, "files-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "files-%d", count); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11272,11 +11094,9 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "size-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "size-%d", count); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11285,11 +11105,9 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "lookups-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "lookups-%d", count); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11298,11 +11116,9 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "status-%d", index); ret = dict_get_int32 (rsp_dict, key, &value32); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "status-%d", count); ret = dict_set_int32 (ctx_dict, key, value32); if (ret) { @@ -11311,11 +11127,9 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "failures-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "failures-%d", count); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11324,11 +11138,9 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "skipped-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "skipped-%d", count); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11336,11 +11148,9 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) "failed to set skipped count"); } } - memset (key, 0, 256); snprintf (key, 256, "run-time-%d", index); ret = dict_get_double (rsp_dict, key, &elapsed_time); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "run-time-%d", count); ret = dict_set_double (ctx_dict, key, elapsed_time); if (ret) { @@ -11349,11 +11159,9 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "demoted-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "demoted-%d", count); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11361,11 +11169,9 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) "failed to set demoted count"); } } - memset (key, 0, 256); snprintf (key, 256, "promoted-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "promoted-%d", count); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -11374,11 +11180,9 @@ glusterd_volume_tier_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict) } } - memset (key, 0, 256); snprintf (key, 256, "time-left-%d", index); ret = dict_get_uint64 (rsp_dict, key, &value); if (!ret) { - memset (key, 0, 256); snprintf (key, 256, "time-left-%d", count); ret = dict_set_uint64 (ctx_dict, key, value); if (ret) { @@ -12127,56 +11931,49 @@ glusterd_tier_or_rebalance_rsp (dict_t *op_ctx, glusterd_rebalance_t *index, int int ret = 0; char key[256] = {0,}; - memset (key, 0 , 256); - snprintf (key, 256, "files-%d", i); + snprintf (key, sizeof (key), "files-%d", i); ret = dict_set_uint64 (op_ctx, key, index->rebalance_files); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, "failed to set file count"); - memset (key, 0 , 256); - snprintf (key, 256, "size-%d", i); + snprintf (key, sizeof (key), "size-%d", i); ret = dict_set_uint64 (op_ctx, key, index->rebalance_data); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, "failed to set size of xfer"); - memset (key, 0 , 256); - snprintf (key, 256, "lookups-%d", i); + snprintf (key, sizeof (key), "lookups-%d", i); ret = dict_set_uint64 (op_ctx, key, index->lookedup_files); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, "failed to set lookedup file count"); - memset (key, 0 , 256); - snprintf (key, 256, "status-%d", i); + snprintf (key, sizeof (key), "status-%d", i); ret = dict_set_int32 (op_ctx, key, index->defrag_status); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, "failed to set status"); - memset (key, 0 , 256); - snprintf (key, 256, "failures-%d", i); + snprintf (key, sizeof (key), "failures-%d", i); ret = dict_set_uint64 (op_ctx, key, index->rebalance_failures); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, "failed to set failure count"); - memset (key, 0 , 256); - snprintf (key, 256, "skipped-%d", i); + snprintf (key, sizeof (key), "skipped-%d", i); ret = dict_set_uint64 (op_ctx, key, index->skipped_files); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, "failed to set skipped count"); - memset (key, 0, 256); - snprintf (key, 256, "run-time-%d", i); + snprintf (key, sizeof (key), "run-time-%d", i); ret = dict_set_double (op_ctx, key, index->rebalance_time); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, 0, @@ -12253,24 +12050,21 @@ glusterd_defrag_volume_node_rsp (dict_t *req_dict, dict_t *rsp_dict, else glusterd_tier_or_rebalance_rsp (op_ctx, &volinfo->rebal, i); - memset (key, 0 , 256); - snprintf (key, 256, "time-left-%d", i); + snprintf (key, sizeof (key), "time-left-%d", i); ret = dict_set_uint64 (op_ctx, key, volinfo->rebal.time_left); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED, "failed to set time left"); - memset (key, 0 , 256); - snprintf (key, 256, "promoted-%d", i); + snprintf (key, sizeof (key), "promoted-%d", i); ret = dict_set_uint64 (op_ctx, key, volinfo->tier_info.promoted); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED, "failed to set lookedup file count"); - memset (key, 0 , 256); - snprintf (key, 256, "demoted-%d", i); + snprintf (key, sizeof (key), "demoted-%d", i); ret = dict_set_uint64 (op_ctx, key, volinfo->tier_info.demoted); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, errno, @@ -12632,7 +12426,6 @@ gd_should_i_start_rebalance (glusterd_volinfo_t *volinfo) { goto out; } for (i = 1; i <= count; i++) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d", i); ret = dict_get_str (volinfo->rebal.dict, key, &brickname); diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index fd256083722..99a0704004d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1587,7 +1587,6 @@ gfproxy_server_graph_builder (volgen_graph_t *graph, return -1; } - memset (key, 0, sizeof (key)); if (password) { snprintf (key, sizeof (key), "auth.login.%s.password", username); @@ -1596,7 +1595,6 @@ gfproxy_server_graph_builder (volgen_graph_t *graph, goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "gfproxyd-%s", volinfo->volname); ret = xlator_set_option (xl, "auth-path", key); @@ -2532,7 +2530,6 @@ brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, } if (username) { - memset (key, 0, sizeof (key)); len = snprintf (key, sizeof (key), "auth.login.%s.allow", brickinfo->path); if ((len < 0) || (len >= sizeof(key))) { @@ -2545,7 +2542,6 @@ brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, } if (password) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "auth.login.%s.password", username); @@ -2554,7 +2550,6 @@ brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, return -1; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "auth-path"); ret = xlator_set_option (xl, key, brickinfo->path); @@ -2566,7 +2561,6 @@ brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, if (volname && !strcmp (volname, GLUSTER_SHARED_STORAGE)) { - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "strict-auth-accept"); ret = xlator_set_option (xl, key, "true"); @@ -2575,7 +2569,6 @@ brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, } if (dict_get_str (volinfo->dict, "auth.ssl-allow", &ssl_user) == 0) { - memset (key, 0, sizeof (key)); len = snprintf (key, sizeof (key), "auth.login.%s.ssl-allow", brickinfo->path); if ((len < 0) || (len >= sizeof(key))) { diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c index bf8132f56a5..6a4415d5b8b 100644 --- a/xlators/nfs/server/src/nfs.c +++ b/xlators/nfs/server/src/nfs.c @@ -1664,7 +1664,6 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict, char *brickname) if (!_nfs_export_is_for_vol (mentry->exname, volname)) continue; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.hostname", count); ret = dict_set_str (dict, key, mentry->hostname); if (ret) { @@ -1677,7 +1676,6 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict, char *brickname) /* No connection data available yet in nfs server. * Hence, setting to 0 to prevent cli failing */ - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.bytesread", count); ret = dict_set_uint64 (dict, key, 0); if (ret) { @@ -1687,7 +1685,6 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict, char *brickname) goto out; } - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.byteswrite", count); ret = dict_set_uint64 (dict, key, 0); if (ret) { diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c index 93f5124acf4..b62e24902c8 100644 --- a/xlators/nfs/server/src/nfs3.c +++ b/xlators/nfs/server/src/nfs3.c @@ -5535,7 +5535,7 @@ nfs3_init_subvolume_options (xlator_t *nfsx, if (gf_nfs_dvm_off (nfs_state (nfsx))) goto no_dvm; - ret = snprintf (searchkey, 1024, "nfs3.%s.volume-id",exp->subvol->name); + ret = snprintf (searchkey, sizeof (searchkey), "nfs3.%s.volume-id",exp->subvol->name); if (ret < 0) { gf_msg (GF_MNT, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, "snprintf failed"); @@ -5574,7 +5574,7 @@ nfs3_init_subvolume_options (xlator_t *nfsx, no_dvm: /* Volume Access */ name = exp->subvol->name; - ret = snprintf (searchkey, 1024, "nfs3.%s.volume-access", name); + ret = snprintf (searchkey, sizeof (searchkey), "nfs3.%s.volume-access", name); if (ret < 0) { gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, "snprintf failed"); @@ -5596,7 +5596,7 @@ no_dvm: exp->access = GF_NFS3_VOLACCESS_RO; } - ret = snprintf (searchkey, 1024, "rpc-auth.%s.unix", name); + ret = snprintf (searchkey, sizeof (searchkey), "rpc-auth.%s.unix", name); if (ret < 0) { gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, "snprintf failed"); @@ -5615,7 +5615,7 @@ no_dvm: } exp->trusted_sync = 0; - ret = snprintf (searchkey, 1024, "nfs3.%s.trusted-sync", name); + ret = snprintf (searchkey, sizeof (searchkey), "nfs3.%s.trusted-sync", name); if (ret < 0) { gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, "snprintf failed"); @@ -5646,7 +5646,7 @@ no_dvm: } exp->trusted_write = 0; - ret = snprintf (searchkey, 1024, "nfs3.%s.trusted-write", name); + ret = snprintf (searchkey, sizeof (searchkey), "nfs3.%s.trusted-write", name); if (ret < 0) { gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, "snprintf failed"); diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index 8ff51a1c16d..73d239f0fb3 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -193,7 +193,6 @@ server_priv_to_dict (xlator_t *this, dict_t *dict, char *brickname) (!strcmp (brickname, xprt->xl_private->bound_xl->name))) { peerinfo = &xprt->peerinfo; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.hostname", count); @@ -202,7 +201,6 @@ server_priv_to_dict (xlator_t *this, dict_t *dict, char *brickname) if (ret) goto unlock; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.bytesread", count); @@ -211,7 +209,6 @@ server_priv_to_dict (xlator_t *this, dict_t *dict, char *brickname) if (ret) goto unlock; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.byteswrite", count); @@ -220,7 +217,6 @@ server_priv_to_dict (xlator_t *this, dict_t *dict, char *brickname) if (ret) goto unlock; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.opversion", count); @@ -229,7 +225,6 @@ server_priv_to_dict (xlator_t *this, dict_t *dict, char *brickname) if (ret) goto unlock; - memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "client%d.name", count); ret = dict_set_str (dict, key, |