summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--newlib/libc/time/time.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/newlib/libc/time/time.c b/newlib/libc/time/time.c
index 2506388f6..9de71d457 100644
--- a/newlib/libc/time/time.c
+++ b/newlib/libc/time/time.c
@@ -43,11 +43,10 @@ _DEFUN (time, (t),
{
struct timeval now;
- if (_gettimeofday_r (_REENT, &now, NULL) >= 0)
- {
- if (t)
- *t = now.tv_sec;
- return now.tv_sec;
- }
- return -1;
+ if (_gettimeofday_r (_REENT, &now, NULL) < 0)
+ now.tv_sec = (time_t) -1;
+
+ if (t)
+ *t = now.tv_sec;
+ return now.tv_sec;
}