From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id BA43A469710 for ; Mon, 18 May 2020 14:13:09 +0300 (MSK) Date: Mon, 18 May 2020 14:13:07 +0300 From: Mergen Imeev Message-ID: <20200518111306.GA12861@tarantool.org> References: <20200518101502.117121-1-gorcunov@gmail.com> <20200518101502.117121-3-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200518101502.117121-3-gorcunov@gmail.com> Subject: Re: [Tarantool-patches] [PATCH 2/5] box/sql: func -- fix compilation warning List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tml , Alexander Turenko On Mon, May 18, 2020 at 01:14:59PM +0300, Cyrill Gorcunov wrote: > The @r is "double" value thus use explicit > conversion to placate clang compiler. > > Signed-off-by: Cyrill Gorcunov > --- > src/box/sql/func.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index 2c510940b..d5463facd 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -845,9 +845,9 @@ roundFunc(sql_context * context, int argc, sql_value ** argv) > * handle the rounding directly, > * otherwise use printf. > */ > - if (n == 0 && r >= 0 && r < LARGEST_INT64 - 1) { > + if (n == 0 && r >= 0 && r < (double)(LARGEST_INT64 - 1)) { > r = (double)((sql_int64) (r + 0.5)); I am not sure that this change worth to do since LARGEST_INT64 = 2^63 -1 and (double)(LARGEST_INT64 - 1) == 2^63, if I am not wrong. I also not sure that this worked right before. I think it makes sense to compare with someting like 2^53, because if absolute value of r is greater that 2^53 than we do not have to round it anymore. > - } else if (n == 0 && r < 0 && (-r) < LARGEST_INT64 - 1) { > + } else if (n == 0 && r < 0 && (-r) < (double)(LARGEST_INT64 - 1)) { > r = -(double)((sql_int64) ((-r) + 0.5)); > } else { > const char *rounded_value = tt_sprintf("%.*f", n, r); > -- > 2.26.2 >