[patch]real2int std_vmod function.

Arianna Aondio arianna.aondio at varnish-software.com
Thu Aug 13 10:42:27 CEST 2015

On Thu, Aug 13, 2015 at 10:30 AM, Poul-Henning Kamp <phk at phk.freebsd.dk> wrote:
> --------
> In message <55CBB949.8030107 at uplex.de>, Geoff Simmons writes:
>>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)
>>+      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

More information about the varnish-dev mailing list