diff options
author | Pranith Kumar K <pranithk@gluster.com> | 2012-06-07 14:01:46 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-06-13 08:28:01 -0700 |
commit | a04bbeafa9b96c0f05e6403749d2b8002b6c4f12 (patch) | |
tree | a29771454fa2033abe793c3200516fcf2dd7e21f | |
parent | 7ded1a6e11dae194f04d8717125ff5c18066731e (diff) |
cli: Fix time_t conversions
Change-Id: I98eb76e5971ea800a249d21557d5dd4f093fdaaf
BUG: 828058
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3534
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Joe Julian <me@joejulian.name>
Reviewed-by: Joe Julian <me@joejulian.name>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r-- | cli/src/cli-rpc-ops.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 434e9a6b13c..dad863cd815 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -5802,8 +5802,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); @@ -5832,9 +5833,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 (<ime, &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 ("-----------------------------------"); |