diff options
| author | Yaniv Kaul <ykaul@redhat.com> | 2018-08-02 16:02:33 +0300 | 
|---|---|---|
| committer | Amar Tumballi <amarts@redhat.com> | 2018-08-14 05:15:04 +0000 | 
| commit | b2b6ab8eff317f6a507ab23897ea6cd5c718d99a (patch) | |
| tree | 45fb1392f535f0236f057d9d9c932feda4f9ab40 /xlators | |
| parent | 32c8f70f49c0e287c53998e37867f00fa775377b (diff) | |
All: remove memset() before sprintf()
It's not needed.
There's a good chance the compiler is smart enough to remove it
anyway, but it can't hurt - I hope.
Compile-tested only!
Change-Id: Id7c054e146ba630227affa591007803f3046416b
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Diffstat (limited to 'xlators')
19 files changed, 69 insertions, 375 deletions
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,  | 
