Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH 0/5] build: fix compilation warning
@ 2020-05-18 10:14 Cyrill Gorcunov
  2020-05-18 10:14 ` [Tarantool-patches] [PATCH 1/5] test: unit/guava -- " Cyrill Gorcunov
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Cyrill Gorcunov @ 2020-05-18 10:14 UTC (permalink / raw)
  To: tml; +Cc: Alexander Turenko

While been working on issue #4614 I've got the series
of compilation problems related to implicit type conversion
(linux,clang-10.0.0). The but itself is not yet resolved
but the fixes in series worth to merge I think.

Please take a look.

branch gorcunov/gh-4614-clang-fix

Cyrill Gorcunov (5):
  test: unit/guava -- fix compilation warning
  box/sql: func -- fix compilation warning
  box/sql: vdbe -- fix compilation warning
  box/sql: vdbemem -- fix compilation warning
  box/vynil: quota -- fix compilation waning

 src/box/sql/func.c    | 4 ++--
 src/box/sql/vdbe.c    | 4 ++--
 src/box/sql/vdbemem.c | 4 ++--
 src/box/vy_quota.h    | 2 +-
 test/unit/guava.c     | 3 ++-
 5 files changed, 9 insertions(+), 8 deletions(-)

-- 
2.26.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Tarantool-patches] [PATCH 1/5] test: unit/guava -- fix compilation warning
  2020-05-18 10:14 [Tarantool-patches] [PATCH 0/5] build: fix compilation warning Cyrill Gorcunov
@ 2020-05-18 10:14 ` Cyrill Gorcunov
  2020-05-18 10:14 ` [Tarantool-patches] [PATCH 2/5] box/sql: func " Cyrill Gorcunov
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Cyrill Gorcunov @ 2020-05-18 10:14 UTC (permalink / raw)
  To: tml; +Cc: Alexander Turenko

Convert to uint64_t explicitly.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 test/unit/guava.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/unit/guava.c b/test/unit/guava.c
index 4e3ced76a..fd496af9e 100644
--- a/test/unit/guava.c
+++ b/test/unit/guava.c
@@ -46,7 +46,8 @@ lcg_compat_check()
 		0, 55, 62, 8, 45, 59, 86, 97, 82, 59,
 		73, 37, 17, 56, 86, 21, 90, 37, 38, 83
 	};
-	for (size_t i = 0; i < sizeof(golden100) / sizeof(int64_t); ++i)
+	uint64_t nr_elems = (uint64_t)sizeof(golden100) / sizeof(uint64_t);
+	for (size_t i = 0; i < nr_elems; ++i)
 		check_guava_correctness(golden100[i]);
 
 	fail_if(6     != guava(10863919174838991ULL, 11));
-- 
2.26.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Tarantool-patches] [PATCH 2/5] box/sql: func -- fix compilation warning
  2020-05-18 10:14 [Tarantool-patches] [PATCH 0/5] build: fix compilation warning Cyrill Gorcunov
  2020-05-18 10:14 ` [Tarantool-patches] [PATCH 1/5] test: unit/guava -- " Cyrill Gorcunov
@ 2020-05-18 10:14 ` Cyrill Gorcunov
  2020-05-18 11:13   ` Mergen Imeev
  2020-05-18 10:15 ` [Tarantool-patches] [PATCH 3/5] box/sql: vdbe " Cyrill Gorcunov
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Cyrill Gorcunov @ 2020-05-18 10:14 UTC (permalink / raw)
  To: tml; +Cc: Alexander Turenko

The @r is "double" value thus use explicit
conversion to placate clang compiler.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 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));
-	} 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Tarantool-patches] [PATCH 3/5] box/sql: vdbe -- fix compilation warning
  2020-05-18 10:14 [Tarantool-patches] [PATCH 0/5] build: fix compilation warning Cyrill Gorcunov
  2020-05-18 10:14 ` [Tarantool-patches] [PATCH 1/5] test: unit/guava -- " Cyrill Gorcunov
  2020-05-18 10:14 ` [Tarantool-patches] [PATCH 2/5] box/sql: func " Cyrill Gorcunov
@ 2020-05-18 10:15 ` Cyrill Gorcunov
  2020-05-18 10:15 ` [Tarantool-patches] [PATCH 4/5] box/sql: vdbemem " Cyrill Gorcunov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Cyrill Gorcunov @ 2020-05-18 10:15 UTC (permalink / raw)
  To: tml; +Cc: Alexander Turenko

pIn3->u.r is a "double", thus placate clang.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 src/box/sql/vdbe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 724bc188b..2b5dde6d2 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -3387,9 +3387,9 @@ case OP_SeekGT: {       /* jump, in3 */
 			i = pIn3->u.u;
 			is_neg = false;
 		} else if ((pIn3->flags & MEM_Real) == MEM_Real) {
-			if (pIn3->u.r > INT64_MAX)
+			if (pIn3->u.r > (double)INT64_MAX)
 				i = INT64_MAX;
-			else if (pIn3->u.r < INT64_MIN)
+			else if (pIn3->u.r < (double)INT64_MIN)
 				i = INT64_MIN;
 			else
 				i = pIn3->u.r;
-- 
2.26.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Tarantool-patches] [PATCH 4/5] box/sql: vdbemem -- fix compilation warning
  2020-05-18 10:14 [Tarantool-patches] [PATCH 0/5] build: fix compilation warning Cyrill Gorcunov
                   ` (2 preceding siblings ...)
  2020-05-18 10:15 ` [Tarantool-patches] [PATCH 3/5] box/sql: vdbe " Cyrill Gorcunov
@ 2020-05-18 10:15 ` Cyrill Gorcunov
  2020-05-18 10:15 ` [Tarantool-patches] [PATCH 5/5] box/vynil: quota -- fix compilation waning Cyrill Gorcunov
  2020-10-01 12:07 ` [Tarantool-patches] [PATCH 0/5] build: fix compilation warning Kirill Yukhin
  5 siblings, 0 replies; 10+ messages in thread
From: Cyrill Gorcunov @ 2020-05-18 10:15 UTC (permalink / raw)
  To: tml; +Cc: Alexander Turenko

d is "double" thus placate clang.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 src/box/sql/vdbemem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c
index 8dad2db9a..9fe611c7c 100644
--- a/src/box/sql/vdbemem.c
+++ b/src/box/sql/vdbemem.c
@@ -686,11 +686,11 @@ sqlVdbeMemCast(Mem * pMem, enum field_type type)
 			double d;
 			if (sqlVdbeRealValue(pMem, &d) != 0)
 				return -1;
-			if (d < INT64_MAX && d >= INT64_MIN) {
+			if (d < (double)INT64_MAX && d >= (double)INT64_MIN) {
 				mem_set_int(pMem, d, d <= -1);
 				return 0;
 			}
-			if (d >= INT64_MAX && d < UINT64_MAX) {
+			if (d >= (double)INT64_MAX && d < (double)UINT64_MAX) {
 				mem_set_u64(pMem, d);
 				return 0;
 			}
-- 
2.26.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Tarantool-patches] [PATCH 5/5] box/vynil: quota -- fix compilation waning
  2020-05-18 10:14 [Tarantool-patches] [PATCH 0/5] build: fix compilation warning Cyrill Gorcunov
                   ` (3 preceding siblings ...)
  2020-05-18 10:15 ` [Tarantool-patches] [PATCH 4/5] box/sql: vdbemem " Cyrill Gorcunov
@ 2020-05-18 10:15 ` Cyrill Gorcunov
  2020-05-19 12:33   ` Nikita Pettik
  2020-10-01 12:07 ` [Tarantool-patches] [PATCH 0/5] build: fix compilation warning Kirill Yukhin
  5 siblings, 1 reply; 10+ messages in thread
From: Cyrill Gorcunov @ 2020-05-18 10:15 UTC (permalink / raw)
  To: tml; +Cc: Alexander Turenko

There is a mixture of types and clang prefer
explicit conversion (since @value is a double).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 src/box/vy_quota.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/box/vy_quota.h b/src/box/vy_quota.h
index 63d4f6a81..bd7d4e03d 100644
--- a/src/box/vy_quota.h
+++ b/src/box/vy_quota.h
@@ -104,7 +104,7 @@ vy_rate_limit_refill(struct vy_rate_limit *rl, double time)
 	double value = rl->value + size;
 	/* Allow bursts up to 2x rate. */
 	value = MIN(value, size * 2);
-	rl->value = MIN(value, SSIZE_MAX);
+	rl->value = MIN((ssize_t)value, SSIZE_MAX);
 }
 
 typedef void
-- 
2.26.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/5] box/sql: func -- fix compilation warning
  2020-05-18 10:14 ` [Tarantool-patches] [PATCH 2/5] box/sql: func " Cyrill Gorcunov
@ 2020-05-18 11:13   ` Mergen Imeev
  2020-05-18 11:32     ` Cyrill Gorcunov
  0 siblings, 1 reply; 10+ messages in thread
From: Mergen Imeev @ 2020-05-18 11:13 UTC (permalink / raw)
  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 <gorcunov@gmail.com>
> ---
>  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
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/5] box/sql: func -- fix compilation warning
  2020-05-18 11:13   ` Mergen Imeev
@ 2020-05-18 11:32     ` Cyrill Gorcunov
  0 siblings, 0 replies; 10+ messages in thread
From: Cyrill Gorcunov @ 2020-05-18 11:32 UTC (permalink / raw)
  To: Mergen Imeev; +Cc: tml, Alexander Turenko

On Mon, May 18, 2020 at 02:13:07PM +0300, Mergen Imeev wrote:
> > @@ -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.

Mergen, I've no clue which limits we have in sql, thus it
is up to you. Either fix it on top either provide a patch
instead please.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Tarantool-patches] [PATCH 5/5] box/vynil: quota -- fix compilation waning
  2020-05-18 10:15 ` [Tarantool-patches] [PATCH 5/5] box/vynil: quota -- fix compilation waning Cyrill Gorcunov
@ 2020-05-19 12:33   ` Nikita Pettik
  0 siblings, 0 replies; 10+ messages in thread
From: Nikita Pettik @ 2020-05-19 12:33 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tml, Alexander Turenko

On 18 May 13:15, Cyrill Gorcunov wrote:
> There is a mixture of types and clang prefer
> explicit conversion (since @value is a double).

LGTM as obvious.
 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>  src/box/vy_quota.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/box/vy_quota.h b/src/box/vy_quota.h
> index 63d4f6a81..bd7d4e03d 100644
> --- a/src/box/vy_quota.h
> +++ b/src/box/vy_quota.h
> @@ -104,7 +104,7 @@ vy_rate_limit_refill(struct vy_rate_limit *rl, double time)
>  	double value = rl->value + size;
>  	/* Allow bursts up to 2x rate. */
>  	value = MIN(value, size * 2);
> -	rl->value = MIN(value, SSIZE_MAX);
> +	rl->value = MIN((ssize_t)value, SSIZE_MAX);
>  }
>  
>  typedef void
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Tarantool-patches] [PATCH 0/5] build: fix compilation warning
  2020-05-18 10:14 [Tarantool-patches] [PATCH 0/5] build: fix compilation warning Cyrill Gorcunov
                   ` (4 preceding siblings ...)
  2020-05-18 10:15 ` [Tarantool-patches] [PATCH 5/5] box/vynil: quota -- fix compilation waning Cyrill Gorcunov
@ 2020-10-01 12:07 ` Kirill Yukhin
  5 siblings, 0 replies; 10+ messages in thread
From: Kirill Yukhin @ 2020-10-01 12:07 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tml, Alexander Turenko

Hello,

On 18 май 13:14, Cyrill Gorcunov wrote:
> While been working on issue #4614 I've got the series
> of compilation problems related to implicit type conversion
> (linux,clang-10.0.0). The but itself is not yet resolved
> but the fixes in series worth to merge I think.
> 
> Please take a look.
> 
> branch gorcunov/gh-4614-clang-fix
> 
> Cyrill Gorcunov (5):
>   test: unit/guava -- fix compilation warning
>   box/sql: func -- fix compilation warning
>   box/sql: vdbe -- fix compilation warning
>   box/sql: vdbemem -- fix compilation warning
>   box/vynil: quota -- fix compilation waning

I've checked your patchset into 2.4, 2.5 and master.

I've also cherry-pick patches #1 and #5 into 1.10.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-10-01 12:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18 10:14 [Tarantool-patches] [PATCH 0/5] build: fix compilation warning Cyrill Gorcunov
2020-05-18 10:14 ` [Tarantool-patches] [PATCH 1/5] test: unit/guava -- " Cyrill Gorcunov
2020-05-18 10:14 ` [Tarantool-patches] [PATCH 2/5] box/sql: func " Cyrill Gorcunov
2020-05-18 11:13   ` Mergen Imeev
2020-05-18 11:32     ` Cyrill Gorcunov
2020-05-18 10:15 ` [Tarantool-patches] [PATCH 3/5] box/sql: vdbe " Cyrill Gorcunov
2020-05-18 10:15 ` [Tarantool-patches] [PATCH 4/5] box/sql: vdbemem " Cyrill Gorcunov
2020-05-18 10:15 ` [Tarantool-patches] [PATCH 5/5] box/vynil: quota -- fix compilation waning Cyrill Gorcunov
2020-05-19 12:33   ` Nikita Pettik
2020-10-01 12:07 ` [Tarantool-patches] [PATCH 0/5] build: fix compilation warning Kirill Yukhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox