Quote from Linux Programmer's Manual: "If t is non-NULL, the return value is also stored in the memory pointed to by t."
Code Review: https://review.source.android.com/#change,23998
From 30a19b9cdbe509d62c7d4c5df9a6daab13ff8857 Mon Sep 17 00:00:00 2001 From: Jim Huang <jim.hu...@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(-) diff --git a/libc/unistd/time.c b/libc/unistd/time.c index 13d7366..7b450c7 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; } -- 1.7.5.4
_______________________________________________ linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev