From 21edf366ea9b5e4dc04c217289fdaf39f08a0060 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Thu, 16 Jun 2011 22:40:10 +0800 Subject: [PATCH] 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 Signed-off-by: Jim Huang --- libc/unistd/time.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libc/unistd/time.c b/libc/unistd/time.c index 13d73661a..7b450c770 100644 --- a/libc/unistd/time.c +++ b/libc/unistd/time.c @@ -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; }