[master] 4dd951312 Adjust vtim.c test code to 32bit time_t
Nils Goroll
nils.goroll at uplex.de
Mon Dec 4 15:33:05 UTC 2023
commit 4dd951312f1f0f2da546a51deeb95508a8b493db
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Mon Dec 4 16:30:41 2023 +0100
Adjust vtim.c test code to 32bit time_t
Fixes vtest error on SunOS gcc4.7.3 -m32:
vtim.c: In function 'main':
vtim.c:605:2: error: overflow in implicit constant conversion [-Werror=overflow]
vtim.c:605:2: error: comparison is always true due to limited range of data type [-Werror=type-limits]
diff --git a/lib/libvarnish/vtim.c b/lib/libvarnish/vtim.c
index 1894fa0ee..8f89fae58 100644
--- a/lib/libvarnish/vtim.c
+++ b/lib/libvarnish/vtim.c
@@ -585,6 +585,9 @@ parse_check(time_t t, const char *s)
}
}
+#define TTEST_MIN (sizeof(time_t) >= 8 ? -2209852800 : INT32_MIN)
+#define TTEST_MAX (sizeof(time_t) >= 8 ? 20000000000 : INT32_MAX)
+
int
main(int argc, char **argv)
{
@@ -602,7 +605,7 @@ main(int argc, char **argv)
bench();
/* Brute force test against libc version */
- for (t = -2209852800; t < 20000000000; t += 3599) {
+ for (t = TTEST_MIN; t < TTEST_MAX; t += 3599) {
gmtime_r(&t, &tm);
strftime(buf1, sizeof buf1, "%a, %d %b %Y %T GMT", &tm);
VTIM_format(t, buf);
More information about the varnish-commit
mailing list