From 70537d8802660c334323ec9281c52154e7471a31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Fri, 28 Sep 2018 08:57:57 +0200 Subject: [PATCH] cn-encoder: Fix -Wdouble-promotion by explicit cast The intention of this line of code is to check whether the conversion to float reduced the precision of the value, hence the conversion to double is correct here, but when compiled with GCC's -Wdouble-promotion, this implicit cast to double will trigger a warning. The fix for the warning is to make the cast explicit. --- src/cn-encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cn-encoder.c b/src/cn-encoder.c index d8a4d49..9ea97ee 100644 --- a/src/cn-encoder.c +++ b/src/cn-encoder.c @@ -116,7 +116,7 @@ static void _write_positive(cn_write_state *ws, cn_cbor_type typ, uint64_t val) static void _write_double(cn_write_state *ws, double val) { float float_val = val; - if (float_val == val) { /* 32 bits is enough and we aren't NaN */ + if ((double)float_val == val) { /* 32 bits is enough and we aren't NaN */ uint32_t be32; uint16_t be16, u16; union {