From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128496 invoked by alias); 7 Sep 2017 13:40:41 -0000 Mailing-List: contact newlib-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-cvs-owner@sourceware.org Received: (qmail 128453 invoked by uid 10080); 7 Sep 2017 13:40:40 -0000 Date: Thu, 07 Sep 2017 13:40:00 -0000 Message-ID: <20170907134040.128450.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Sebastian Huber To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Remove harmful casts in gmtime_r() X-Act-Checkin: newlib-cygwin X-Git-Author: Sebastian Huber X-Git-Refname: refs/heads/master X-Git-Oldrev: f9205f1d470ed1a214b841b6d2fd60fea14954cb X-Git-Newrev: ad45b86533a47ae33ec99cebc61aee96b57e17a5 X-SW-Source: 2017-q3/txt/msg00068.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ad45b86533a47ae33ec99cebc61aee96b57e17a5 commit ad45b86533a47ae33ec99cebc61aee96b57e17a5 Author: Sebastian Huber 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 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;