summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/common-utils.c3
-rw-r--r--libglusterfs/src/common-utils.h14
2 files changed, 10 insertions, 7 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 09f0caa7e8a..d7888f526df 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -3097,9 +3097,8 @@ static const char *__gf_zerotimes[] = {
};
void
-_gf_timestuff (gf_timefmts *fmt, const char ***fmts, const char ***zeros)
+_gf_timestuff (const char ***fmts, const char ***zeros)
{
- *fmt = gf_timefmt_last;
*fmts = __gf_timefmts;
*zeros = __gf_zerotimes;
}
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 569147e3718..fc581de4998 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -698,19 +698,23 @@ typedef enum {
static inline char *
gf_time_fmt (char *dst, size_t sz_dst, time_t utime, unsigned int fmt)
{
- extern void _gf_timestuff (gf_timefmts *, const char ***, const char ***);
+ extern void _gf_timestuff (const char ***, const char ***);
static gf_timefmts timefmt_last = (gf_timefmts) - 1;
static const char **fmts;
static const char **zeros;
struct tm tm, *res;
int localtime = 0;
- if (timefmt_last == (gf_timefmts) - 1)
- _gf_timestuff (&timefmt_last, &fmts, &zeros);
- if (timefmt_last < fmt) fmt = gf_timefmt_default;
+ if (timefmt_last == ((gf_timefmts)-1)) {
+ _gf_timestuff (&fmts, &zeros);
+ timefmt_last = gf_timefmt_last;
+ }
+ if (timefmt_last <= fmt) {
+ fmt = gf_timefmt_default;
+ }
localtime = gf_log_get_localtime ();
res = localtime ? localtime_r (&utime, &tm) : gmtime_r (&utime, &tm);
- if (utime && res != NULL) {
+ if (utime && (res != NULL)) {
strftime (dst, sz_dst, fmts[fmt], &tm);
} else {
strncpy (dst, "N/A", sz_dst);