Module Name: src
Committed By: christos
Date: Sun Feb 13 23:58:40 UTC 2011
Modified Files:
src/lib/libc/time: localtime.c
Log Message:
Don't forget to set errno. Pointed out by yamt.
To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/lib/libc/time/localtime.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/time/localtime.c
diff -u src/lib/libc/time/localtime.c:1.54 src/lib/libc/time/localtime.c:1.55
--- src/lib/libc/time/localtime.c:1.54 Sat Jan 15 10:42:10 2011
+++ src/lib/libc/time/localtime.c Sun Feb 13 18:58:40 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: localtime.c,v 1.54 2011/01/15 15:42:10 christos Exp $ */
+/* $NetBSD: localtime.c,v 1.55 2011/02/13 23:58:40 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
#if 0
static char elsieid[] = "@(#)localtime.c 8.9";
#else
-__RCSID("$NetBSD: localtime.c,v 1.54 2011/01/15 15:42:10 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.55 2011/02/13 23:58:40 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -1477,7 +1477,12 @@
struct tm *
gmtime(const time_t *const timep)
{
- return gmtsub(NULL, timep, 0L, &tm);
+ struct tm *tmp = gmtsub(NULL, timep, 0L, &tm);
+
+ if (tmp == NULL)
+ errno = EOVERFLOW;
+
+ return tmp;
}
/*
@@ -1487,7 +1492,12 @@
struct tm *
gmtime_r(const time_t * const timep, struct tm *tmp)
{
- return gmtsub(NULL, timep, 0L, tmp);
+ tmp = gmtsub(NULL, timep, 0L, tmp);
+
+ if (tmp == NULL)
+ errno = EOVERFLOW;
+
+ return tmp;
}
#ifdef STD_INSPIRED
@@ -1495,13 +1505,23 @@
struct tm *
offtime(const time_t *const timep, long offset)
{
- return gmtsub(NULL, timep, offset, &tm);
+ struct tm *tmp = gmtsub(NULL, timep, offset, &tm);
+
+ if (tmp == NULL)
+ errno = EOVERFLOW;
+
+ return tmp;
}
struct tm *
offtime_r(const time_t *timep, long offset, struct tm *tmp)
{
- return gmtsub(NULL, timep, offset, tmp);
+ tmp = gmtsub(NULL, timep, offset, tmp);
+
+ if (tmp == NULL)
+ errno = EOVERFLOW;
+
+ return tmp;
}
#endif /* defined STD_INSPIRED */