This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH] libc/time/gmtime_r.c, libc/time/lcltime_r.c,, libc/time/local.h, libc/time/mktm_r.c: move localtime related functionality, from _mktm_r() to new _mklocaltm_r() to break dependency of gmtime() on, timezones
- From: Freddie Chopin <freddie_chopin at op dot pl>
- To: newlib at sourceware dot org
- Date: Sat, 18 Oct 2014 15:42:26 +0200
- Subject: Re: [PATCH] libc/time/gmtime_r.c, libc/time/lcltime_r.c,, libc/time/local.h, libc/time/mktm_r.c: move localtime related functionality, from _mktm_r() to new _mklocaltm_r() to break dependency of gmtime() on, timezones
- Authentication-results: sourceware.org; auth=none
- References: <54077334 dot 6050804 at op dot pl> <540A36F0 dot 6090903 at op dot pl> <540F7654 dot 7070403 at op dot pl> <1330566861 dot 45960793 dot 1410465086152 dot JavaMail dot zimbra at redhat dot com> <5412038C dot 3010800 at op dot pl> <20141014111611 dot GA23418 at calimero dot vinschen dot de>
On 10/14/2014 01:16 PM, Corinna Vinschen wrote:
Hi Freddie,
...
With this patch applied, a Coverity scan shows this new problem:
*** CID 74279: Logically dead code (DEADCODE)
/newlib/libc/time/gmtime_r.c: 52 in gmtime_r()
46 {
47 rem += SECSPERDAY;
48 --days;
49 }
50 while (rem >= SECSPERDAY)
51 {
>>> CID 74279: Logically dead code (DEADCODE)
>>> Execution cannot reach this statement: "rem -= 86400L;".
52 rem -= SECSPERDAY;
53 ++days;
54 }
55
56 /* compute hour, min, and sec */
57 res->tm_hour = (int) (rem / SECSPERHOUR);
AFAICS, Coverity is right. The code starts with
rem = ((long)lcltime) % SECSPERDAY;
thus lcltime is always < SECSPERDAY. Is that just an oversight in
removing some unused code, or does that point to some other problem,
perhaps?
Small oversight only (; I attach a patch with changelog entry.
Regards,
FCh
Attachment:
ChangeLog.txt
Description: Text document
diff --git a/newlib/libc/time/gmtime_r.c b/newlib/libc/time/gmtime_r.c
index 1111cbc..8944845 100644
--- a/newlib/libc/time/gmtime_r.c
+++ b/newlib/libc/time/gmtime_r.c
@@ -47,11 +47,6 @@
rem += SECSPERDAY;
--days;
}
- while (rem >= SECSPERDAY)
- {
- rem -= SECSPERDAY;
- ++days;
- }
/* compute hour, min, and sec */
res->tm_hour = (int) (rem / SECSPERHOUR);
- References:
- [PATCH] libc/time/gmtime_r.c, libc/time/lcltime_r.c,, libc/time/local.h, libc/time/mktm_r.c: move localtime related functionality, from _mktm_r() to new _mklocaltm_r() to break dependency of gmtime() on, timezones
- Re: [PATCH] libc/time/gmtime_r.c, libc/time/lcltime_r.c,, libc/time/local.h, libc/time/mktm_r.c: move localtime related functionality, from _mktm_r() to new _mklocaltm_r() to break dependency of gmtime() on, timezones
- Re: [PATCH] libc/time/gmtime_r.c, libc/time/lcltime_r.c,, libc/time/local.h, libc/time/mktm_r.c: move localtime related functionality, from _mktm_r() to new _mklocaltm_r() to break dependency of gmtime() on, timezones
- Re: [PATCH] libc/time/gmtime_r.c, libc/time/lcltime_r.c,, libc/time/local.h, libc/time/mktm_r.c: move localtime related functionality, from _mktm_r() to new _mklocaltm_r() to break dependency of gmtime() on, timezones
- Re: [PATCH] libc/time/gmtime_r.c, libc/time/lcltime_r.c,, libc/time/local.h, libc/time/mktm_r.c: move localtime related functionality, from _mktm_r() to new _mklocaltm_r() to break dependency of gmtime() on, timezones
- Re: [PATCH] libc/time/gmtime_r.c, libc/time/lcltime_r.c,, libc/time/local.h, libc/time/mktm_r.c: move localtime related functionality, from _mktm_r() to new _mklocaltm_r() to break dependency of gmtime() on, timezones