From bb6279fe6061ab82f18d8616f22b2f543a451eb9 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Fri, 1 Apr 2022 18:20:39 +0800 Subject: [PATCH] libc/lib_localtime:fix deadcode isdst always is false Signed-off-by: anjiahao --- libs/libc/time/lib_localtime.c | 36 +++------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/libs/libc/time/lib_localtime.c b/libs/libc/time/lib_localtime.c index 66e90c7ab9..b514e86e03 100644 --- a/libs/libc/time/lib_localtime.c +++ b/libs/libc/time/lib_localtime.c @@ -1518,9 +1518,7 @@ static int tzparse(FAR const char *name, FAR struct state_s *sp, else { int_fast32_t theirstdoffset; - int_fast32_t theirdstoffset; int_fast32_t theiroffset; - int isdst; int i; int j; @@ -1529,7 +1527,7 @@ static int tzparse(FAR const char *name, FAR struct state_s *sp, return -1; } - /* Initial values of theirstdoffset and theirdstoffset */ + /* Initial value of theirstdoffset */ theirstdoffset = 0; for (i = 0; i < sp->timecnt; ++i) @@ -1542,20 +1540,8 @@ static int tzparse(FAR const char *name, FAR struct state_s *sp, } } - theirdstoffset = 0; - for (i = 0; i < sp->timecnt; ++i) - { - j = sp->types[i]; - if (sp->ttis[j].tt_isdst) - { - theirdstoffset = -sp->ttis[j].tt_gmtoff; - break; - } - } - /* Initially we're assumed to be in standard time */ - isdst = FALSE; theiroffset = theirstdoffset; /* Now juggle transition times and types @@ -1578,29 +1564,13 @@ static int tzparse(FAR const char *name, FAR struct state_s *sp, * offset to the transition time; * otherwise, add the standard time * offset to the transition time. - * - * Transitions from DST to DDST - * will effectively disappear since - * POSIX provides for only one DST - * offset. */ - if (isdst && !sp->ttis[j].tt_ttisstd) - { - sp->ats[i] += dstoffset - theirdstoffset; - } - else - { - sp->ats[i] += stdoffset - theirstdoffset; - } + sp->ats[i] += stdoffset - theirstdoffset; } theiroffset = -sp->ttis[j].tt_gmtoff; - if (sp->ttis[j].tt_isdst) - { - theirdstoffset = theiroffset; - } - else + if (!sp->ttis[j].tt_isdst) { theirstdoffset = theiroffset; }