From: Andres Freund Date: Sun, 1 Apr 2018 03:26:47 +0000 (-0700) Subject: Fix non-portable use of round(). X-Git-Tag: REL_11_BETA1~405 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=686d399f2be6eea4b74d59cdadd427d09cb0e246;p=postgresql Fix non-portable use of round(). round() is from C99. Use rint() instead. There are behavioral differences between round() and rint(), but they should not matter to the Bloom filter optimal_k() function. We already assume POSIX behavior for rint(), so there is no question of rint() not using "rounds towards nearest" as its rounding mode. Cleanup from commit 51bc271790eb234a1ba4d14d3e6530f70de92ab5. Per buildfarm member thrips. Author: Peter Geoghegan Discussion: https://postgr.es/m/CAH2-Wzn76eCGUonARy-wrVtMHsf+4cvbK_oJAWTLfORTU5ki0w@mail.gmail.com --- diff --git a/src/backend/lib/bloomfilter.c b/src/backend/lib/bloomfilter.c index eb08f4a7b8..3565480d13 100644 --- a/src/backend/lib/bloomfilter.c +++ b/src/backend/lib/bloomfilter.c @@ -240,7 +240,7 @@ my_bloom_power(uint64 target_bitset_bits) static int optimal_k(uint64 bitset_bits, int64 total_elems) { - int k = round(log(2.0) * bitset_bits / total_elems); + int k = rint(log(2.0) * bitset_bits / total_elems); return Max(1, Min(k, MAX_HASH_FUNCS)); }