From 30a19b9cdbe509d62c7d4c5df9a6daab13ff8857 Mon Sep 17 00:00:00 2001
From: Jim Huang <jim.huang@linaro.org>
Date: Thu, 16 Jun 2011 22:40:10 +0800
Subject: [PATCH 2/2] time: Improve C99 compliance
Quote from Linux Programmer's Manual:
"If t is non-NULL, the return value is also stored in the memory
pointed to by t."
Change-Id: I8cb66b67e5f34c536ce2f0db76a6dc337c42ea3f
---
libc/unistd/time.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
@@ -34,12 +34,15 @@ time_t
time(time_t *t)
{
struct timeval tt;
+ time_t ret;
if (gettimeofday(&tt, (struct timezone *)0) < 0)
- return (-1);
- if (t)
- *t = (time_t)tt.tv_sec;
- return (tt.tv_sec);
+ ret = -1;
+ else
+ ret = tt.tv_sec;
+ if (t != NULL)
+ *t = ret;
+ return ret;
}
--
1.7.5.4