[patch]real2int std_vmod function.
Poul-Henning Kamp
phk at phk.freebsd.dk
Thu Aug 13 10:30:58 CEST 2015
--------
In message <55CBB949.8030107 at uplex.de>, 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.
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
More information about the varnish-dev
mailing list