On Thu, Aug 13, 2015 at 10:30 AM, Poul-Henning Kamp <[email protected]> wrote: > -------- > In message <[email protected]>, Geoff Simmons writes: >>-----BEGIN PGP SIGNED MESSAGE----- >>Hash: SHA256 >> >>On 8/12/15 5:16 PM, Arianna Aondio wrote: >>> Hi, as discussed this afternoon on IRC with Federico, here is a >>> patch for a std_vmod function for converting from real to int. >> >>+VCL_INT __match_proto__(td_std_time2real) >>+vmod_real2integer(VRT_CTX, VCL_REAL r) >>+{ >>+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); >>+ >>+ return((long)floor(r)); >>+} >> >>Do we have to worry about what happens if r is non-finite (+-Inf or >>NaN)? (Is that possible for a VCL_REAL?) > > Yes. > > Proper range checking should be done, and like all other conversions, > a default value parameter to use when that fails should be added.
Range control should also be added to functions such as real2time, time2integer, time2real. I'm also tempted to restrict the range just to positive numbers. -- Arianna Aondio Software Developer | Varnish Software AS Mobile: +47 98062619 We Make Websites Fly www.varnish-software.com _______________________________________________ varnish-dev mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
