From: Paul Eggert Date: Thu, 5 Jan 2012 00:04:38 +0000 (-0800) Subject: test-posixtm: don't assume signed integer wraparound X-Git-Tag: v0.1~1307 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=65c8c0b8a2060af8af5afdf1e1ff979b7f727b01;p=gnulib.git 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 . --- diff --git a/ChangeLog b/ChangeLog index 17e9ab376..0f554e6d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2012-01-04 Paul Eggert + 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 + . + 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 229c82c28..8400c39f3 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. */