summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-06-07 14:01:46 +0530
committerAnand Avati <avati@redhat.com>2012-06-12 21:27:35 -0700
commit2fde351b8228720bc13f8bea3453b6af1d68c5ad (patch)
tree7928b609e5feb8a26cf5b82f6a5c96053934ed89 /cli/src
parent72301d4d542e5960c7f48832887b60c7dfff136f (diff)
cli: Fix time_t conversions
BUG: 828058 Change-Id: I2511a0473d9310d3a51d0994f415a5d319bfc98b Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/3550 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-rpc-ops.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 091c74f5406..313484cf4f9 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -5859,8 +5859,9 @@ cmd_heal_volume_brick_out (dict_t *dict, int brick)
char *status = NULL;
uint64_t i = 0;
uint32_t time = 0;
- char timestr[256];
- struct tm *tm = NULL;
+ char timestr[256] = {0};
+ struct tm tm = {0};
+ time_t ltime = 0;
snprintf (key, sizeof (key), "%d-hostname", brick);
ret = dict_get_str (dict, key, &hostname);
@@ -5889,9 +5890,15 @@ cmd_heal_volume_brick_out (dict_t *dict, int brick)
if (!time) {
cli_out ("%s", path);
} else {
- tm = localtime ((time_t*)(&time));
- strftime (timestr, sizeof (timestr),
- "%Y-%m-%d %H:%M:%S", tm);
+ ltime = time;
+ memset (&tm, 0, sizeof (tm));
+ if (!localtime_r (&ltime, &tm)) {
+ snprintf (timestr, sizeof (timestr),
+ "Invalid time");
+ } else {
+ strftime (timestr, sizeof (timestr),
+ "%Y-%m-%d %H:%M:%S", &tm);
+ }
if (i ==0) {
cli_out ("at path on brick");
cli_out ("-----------------------------------");