[master] 4177fea VNUM_2bytes doesn't actually work once we get into ExaBytes, because it uses a 'double' which only has approx 52 bits of mantissa, which is marginal already for PetaBytes.
Poul-Henning Kamp
phk at FreeBSD.org
Sat Nov 18 21:42:07 UTC 2017
commit 4177feae6dc57b10e8d4abd7746fa524b9e045e4
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sat Nov 18 21:39:26 2017 +0000
VNUM_2bytes doesn't actually work once we get into ExaBytes, because
it uses a 'double' which only has approx 52 bits of mantissa, which is
marginal already for PetaBytes.
Test various edge-cases.
diff --git a/lib/libvarnish/vnum.c b/lib/libvarnish/vnum.c
index 5e30fc3..f01aa67 100644
--- a/lib/libvarnish/vnum.c
+++ b/lib/libvarnish/vnum.c
@@ -211,10 +211,6 @@ VNUM_2bytes(const char *p, uintmax_t *r, uintmax_t rel)
fval *= (uintmax_t)1 << 50;
++end;
break;
- case 'e': case 'E':
- fval *= (uintmax_t)1 << 60;
- ++end;
- break;
default:
break;
}
@@ -270,6 +266,11 @@ static struct test_case {
{ "1.3TB", (uintmax_t)0, (uintmax_t)1429365116109ULL },
{ "1.7TB", (uintmax_t)0, (uintmax_t)1869169767219ULL },
+ { "1125899906842624", (uintmax_t)0, (uintmax_t)1125899906842624ULL},
+ { "1P", (uintmax_t)0, (uintmax_t)1125899906842624ULL},
+ { "1PB", (uintmax_t)0, (uintmax_t)1125899906842624ULL},
+ { "1.3 PB", (uintmax_t)0, (uintmax_t)1463669878895411ULL},
+
{ "1%", (uintmax_t)1024, (uintmax_t)10 },
{ "2%", (uintmax_t)1024, (uintmax_t)20 },
{ "3%", (uintmax_t)1024, (uintmax_t)31 },
@@ -355,6 +356,15 @@ main(int argc, char *argv[])
++ec;
}
}
+ if (!isnan(VNUM_duration(NULL))) {
+ printf("%s: VNUM_Duration(NULL) fail\n", *argv);
+ ++ec;
+ }
+ d1 = VNUM_duration(" 365.24219d ");
+ if (d1 != 31556925.216) {
+ printf("%s: VNUM_Duration() wrong: %g\n", *argv, d1);
+ ++ec;
+ }
/* TODO: test invalid strings */
if (!ec)
printf("OK\n");
More information about the varnish-commit
mailing list