From 6a270f249904b4185508b3997f11342f75b69784 Mon Sep 17 00:00:00 2001 From: wollman Date: Sat, 19 Jul 2003 02:53:46 +0000 Subject: [PATCH] C99 compliance: time() always sets its return value in both places (if present), even on error. Pointed out by: Wojtek Lerch, on the Austin Group mailing-list --- lib/libc/gen/time.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/libc/gen/time.c b/lib/libc/gen/time.c index 21548335fe26..4468b0154015 100644 --- a/lib/libc/gen/time.c +++ b/lib/libc/gen/time.c @@ -45,10 +45,13 @@ time(t) time_t *t; { struct timeval tt; + time_t retval; if (gettimeofday(&tt, (struct timezone *)0) < 0) - return (-1); - if (t) - *t = tt.tv_sec; - return (tt.tv_sec); + retval = -1; + else + retval = tt.tv_sec; + if (t != NULL) + *t = retval; + return (retval); }