diff options
| author | onelife.real <[email protected]> | 2011-06-17 03:24:04 +0000 |
|---|---|---|
| committer | onelife.real <[email protected]> | 2011-06-17 03:24:04 +0000 |
| commit | e74ca7fc9fea667144d701a3e5ff207f76414af5 (patch) | |
| tree | a9dfdeffc4b055047fac0adfad535ba80e2fa3d8 /components | |
| parent | 6904f495e1ed5edbf6b644e1d66397d26aaa9ec2 (diff) | |
minilibc:
Fix a bug in time functions
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1520 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components')
| -rw-r--r-- | components/libc/minilibc/time.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/components/libc/minilibc/time.c b/components/libc/minilibc/time.c index 602471fb1b..a8595c0fa8 100644 --- a/components/libc/minilibc/time.c +++ b/components/libc/minilibc/time.c @@ -70,7 +70,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r) struct tm* localtime_r(const time_t* t, struct tm* r)
{
time_t tmp;
- struct timezone tz;
+ struct timezone tz = {0};
gettimeofday(0, &tz);
timezone = tz.tz_minuteswest * 60L;
tmp = *t + timezone;
@@ -134,8 +134,9 @@ time_t timegm(struct tm * const t) This is not intuitive. Most mktime implementations do not support
dates after 2059, anyway, so we might leave this out for it's
bloat. */
- if ((years -= 131) >= 0)
+ if (years >= 131)
{
+ years -= 131;
years /= 100;
day -= (years >> 2) * 3 + 1;
if ((years &= 3) == 3)
@@ -159,7 +160,7 @@ time_t timegm(struct tm * const t) time_t mktime(register struct tm* const t)
{
time_t x = timegm(t);
- struct timezone tz;
+ struct timezone tz = {0};
gettimeofday(0, &tz);
timezone = tz.tz_minuteswest * 60L;
x += timezone;
|
