Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/time put back part of the code that determines the ...



details:   https://anonhg.NetBSD.org/src/rev/05e9172de8b0
branches:  trunk
changeset: 347869:05e9172de8b0
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Sep 20 13:09:08 2016 +0000

description:
put back part of the code that determines the smallest of INT_MAX and
SIZE_MAX to avoid llvm truncation warning.

diffstat:

 lib/libc/time/zic.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r 2523e7827e14 -r 05e9172de8b0 lib/libc/time/zic.c
--- a/lib/libc/time/zic.c       Tue Sep 20 09:24:12 2016 +0000
+++ b/lib/libc/time/zic.c       Tue Sep 20 13:09:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zic.c,v 1.60 2016/09/19 18:43:23 christos Exp $        */
+/*     $NetBSD: zic.c,v 1.61 2016/09/20 13:09:08 christos Exp $        */
 /*
 ** This file is in the public domain, so clarified as of
 ** 2006-07-17 by Arthur David Olson.
@@ -10,7 +10,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: zic.c,v 1.60 2016/09/19 18:43:23 christos Exp $");
+__RCSID("$NetBSD: zic.c,v 1.61 2016/09/20 13:09:08 christos Exp $");
 #endif /* !defined lint */
 
 #include "private.h"
@@ -437,8 +437,9 @@
        if (nitems < *nitems_alloc)
                return ptr;
        else {
-               size_t nitems_max = INT_MAX - WORK_AROUND_QTBUG_53071;
-               int amax = nitems_max < SIZE_MAX ? nitems_max : SIZE_MAX;
+               static const int imax = INT_MAX < SIZE_MAX ? INT_MAX : SIZE_MAX;
+               int nitems_max = imax - WORK_AROUND_QTBUG_53071;
+               int amax = nitems_max < imax ? nitems_max : imax;
                if ((amax - 1) / 3 * 2 < *nitems_alloc)
                        memory_exhausted(_("int overflow"));
                *nitems_alloc = *nitems_alloc + (*nitems_alloc >> 1) + 1;



Home | Main Index | Thread Index | Old Index