Unverified Commit 1a931537 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

timediff: fix math for unsigned time_t

parent 114a02c7
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *                             \___|\___/|_| \_\_____|
 *
 *
 * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 *
 * This software is licensed as described in the file COPYING, which
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * you should have received as part of this distribution. The terms
@@ -187,7 +187,7 @@ struct curltime Curl_now(void)
 */
 */
timediff_t Curl_timediff(struct curltime newer, struct curltime older)
timediff_t Curl_timediff(struct curltime newer, struct curltime older)
{
{
  timediff_t diff = newer.tv_sec-older.tv_sec;
  timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec;
  if(diff >= (TIME_MAX/1000))
  if(diff >= (TIME_MAX/1000))
    return TIME_MAX;
    return TIME_MAX;
  else if(diff <= (TIME_MIN/1000))
  else if(diff <= (TIME_MIN/1000))
@@ -201,7 +201,7 @@ timediff_t Curl_timediff(struct curltime newer, struct curltime older)
 */
 */
timediff_t Curl_timediff_us(struct curltime newer, struct curltime older)
timediff_t Curl_timediff_us(struct curltime newer, struct curltime older)
{
{
  timediff_t diff = newer.tv_sec-older.tv_sec;
  timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec;
  if(diff >= (TIME_MAX/1000000))
  if(diff >= (TIME_MAX/1000000))
    return TIME_MAX;
    return TIME_MAX;
  else if(diff <= (TIME_MIN/1000000))
  else if(diff <= (TIME_MIN/1000000))