public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Sebastian Huber <sh@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] Remove harmful casts in gmtime_r()
Date: Thu, 07 Sep 2017 13:40:00 -0000 [thread overview]
Message-ID: <20170907134040.128450.qmail@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ad45b86533a47ae33ec99cebc61aee96b57e17a5
commit ad45b86533a47ae33ec99cebc61aee96b57e17a5
Author: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Thu Sep 7 15:01:47 2017 +0200
Remove harmful casts in gmtime_r()
In case time_t is long, then the cast to long is a nop. In case time_t
is __int_least64_t, then the cast to long may truncate the value before
the division.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Diff:
---
newlib/libc/time/gmtime_r.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/newlib/libc/time/gmtime_r.c b/newlib/libc/time/gmtime_r.c
index 81c7c94..6475df3 100644
--- a/newlib/libc/time/gmtime_r.c
+++ b/newlib/libc/time/gmtime_r.c
@@ -56,8 +56,8 @@ _DEFUN (gmtime_r, (tim_p, res),
unsigned erayear, yearday, month, day;
unsigned long eraday;
- days = ((long)lcltime) / SECSPERDAY + EPOCH_ADJUSTMENT_DAYS;
- rem = ((long)lcltime) % SECSPERDAY;
+ days = lcltime / SECSPERDAY + EPOCH_ADJUSTMENT_DAYS;
+ rem = lcltime % SECSPERDAY;
if (rem < 0)
{
rem += SECSPERDAY;
reply other threads:[~2017-09-07 13:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170907134040.128450.qmail@sourceware.org \
--to=sh@sourceware.org \
--cc=newlib-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).