coreutils
[Top][All Lists]
Advanced

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

Re: coreutils-8.14.116-1e18d on HP-UX 11.00


From: Paul Eggert
Subject: Re: coreutils-8.14.116-1e18d on HP-UX 11.00
Date: Wed, 04 Jan 2012 16:08:25 -0800
User-agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0

On 01/04/12 15:11, Bruno Haible wrote:
> 190112132045.51 return value mismatch: got 0, expected 1
> skipping 190112132045.52: result is out of range of your time_t

That test assumes that signed integer overflow wraps around,
which isn't a safe assumption these days.  I pushed this
to remove the assumption.  I don't know if this'll fix the
problem on HP-UX, but it does fix a portability bug.

>From 78f4bb60feed11a5241fec297d8250c1b11cc5b2 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Wed, 4 Jan 2012 16:04:38 -0800
Subject: [PATCH] test-posixtm: don't assume signed integer wraparound

* tests/test-posixtm.c (main): Don't assume wraparound semantics
after signed integer overflow.  Inspired by (though it may not
fix) Bruno Haible's bug report in
<http://lists.gnu.org/archive/html/bug-gnulib/2012-01/msg00066.html>.
---
 ChangeLog            |    6 ++++++
 tests/test-posixtm.c |    7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 17e9ab3..0f554e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2012-01-04  Paul Eggert  <address@hidden>
 
+       test-posixtm: don't assume signed integer wraparound
+       * tests/test-posixtm.c (main): Don't assume wraparound semantics
+       after signed integer overflow.  Inspired by (though it may not
+       fix) Bruno Haible's bug report in
+       <http://lists.gnu.org/archive/html/bug-gnulib/2012-01/msg00066.html>.
+
        Spell out "Windows 9x" and "Windows XP".
        * lib/poll.c, lib/select.c: In comments, replace "Win9x" with
        "Windows 9x" and "WinXP" with "Windows XP".
diff --git a/tests/test-posixtm.c b/tests/test-posixtm.c
index 229c82c..8400c39 100644
--- a/tests/test-posixtm.c
+++ b/tests/test-posixtm.c
@@ -118,7 +118,7 @@ main (void)
   for (i = 0; T[i].in; i++)
     {
       time_t t_out;
-      time_t t_exp = T[i].t_expected;
+      time_t t_exp;
       bool ok;
 
       /* Some tests assume that time_t is signed.
@@ -130,13 +130,16 @@ main (void)
           continue;
         }
 
-      if (T[i].valid && t_exp != T[i].t_expected)
+      if (! (TYPE_MINIMUM (time_t) <= T[i].t_expected
+             && T[i].t_expected <= TYPE_MAXIMUM (time_t)))
         {
           printf ("skipping %s: result is out of range of your time_t\n",
                   T[i].in);
           continue;
         }
 
+      t_exp = T[i].t_expected;
+
       /* If an input string does not specify the year number, determine
          the expected output by calling posixtime with an otherwise
          equivalent string that starts with the current year.  */
-- 
1.7.6.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]