Tarantool development patches archive
 help / color / mirror / Atom feed
From: Timur Safin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: <imeevma@tarantool.org>
Cc: <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH 1/1] Fix SQL MEM-related warnings
Date: Fri, 23 Apr 2021 02:12:28 +0300	[thread overview]
Message-ID: <002201d737cc$f6d6fe60$e484fb20$@tarantool.org> (raw)
In-Reply-To: <6c835ab6030cd1c20095a36d136b13dacd40f82f.1618848143.git.imeevma@gmail.com>

Could you please put to the description some brief explanation which
problems do you fix here? (link to analysis is preferred, but if it's 
not generally accessible then excerpts from report would be enough)

At the moment it's not entirely clear which problems here fixed.

Thanks,
Timur

: -----Original Message-----
: From: imeevma@tarantool.org <imeevma@tarantool.org>
: Sent: Monday, April 19, 2021 7:04 PM
: To: tsafin@tarantool.org
: Cc: tarantool-patches@dev.tarantool.org
: Subject: [PATCH 1/1] Fix SQL MEM-related warnings
: 
: https://github.com/tarantool/tarantool/issues/5818
: https://github.com/tarantool/tarantool/tree/imeevma/gh-5818-follow-up
: 
: ---
:  src/box/sql/func.c |  3 ++-
:  src/box/sql/mem.c  | 11 ++++++-----
:  2 files changed, 8 insertions(+), 6 deletions(-)
: 
: diff --git a/src/box/sql/func.c b/src/box/sql/func.c
: index 9c28d5122..8d81a2ed3 100644
: --- a/src/box/sql/func.c
: +++ b/src/box/sql/func.c
: @@ -343,6 +343,7 @@ position_func(struct sql_context *context, int argc,
: struct Mem **argv)
:  			 */
:  			haystack_str = mem_as_ustr(haystack);
:  			needle_str = mem_as_ustr(needle);
: +			assert(needle_str != NULL && haystack_str != NULL);
: 
:  			int n_needle_chars =
:  				sql_utf8_char_count(needle_str, n_needle_bytes);
: @@ -569,7 +570,7 @@ roundFunc(sql_context * context, int argc, sql_value **
: argv)
:  	} 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);
: +		const char *rounded_value = tt_sprintf("%.*f", (int)n, r);
:  		sqlAtoF(rounded_value, &r, sqlStrlen30(rounded_value));
:  	}
:  	sql_result_double(context, r);
: diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
: index b6ff6397f..0f41ba0d8 100644
: --- a/src/box/sql/mem.c
: +++ b/src/box/sql/mem.c
: @@ -70,7 +70,7 @@ mem_str(const struct Mem *mem)
:  	case MEM_Int:
:  		return tt_sprintf("%lld", mem->u.i);
:  	case MEM_UInt:
: -		return tt_sprintf("%llu", mem->u.u);
: +		return tt_sprintf("%lu", mem->u.u);
:  	case MEM_Real:
:  		sql_snprintf(BUF_SIZE, &buf[0], "%!.15g", mem->u.r);
:  		return tt_sprintf("%s", buf);
: @@ -520,7 +520,7 @@ int_to_str0(struct Mem *mem)
:  {
:  	const char *str;
:  	if ((mem->flags & MEM_UInt) != 0)
: -		str = tt_sprintf("%llu", mem->u.u);
: +		str = tt_sprintf("%lu", mem->u.u);
:  	else
:  		str = tt_sprintf("%lld", mem->u.i);
:  	return mem_copy_str0(mem, str);
: @@ -729,7 +729,8 @@ double_to_bool(struct Mem *mem)
:  static inline int
:  bool_to_int(struct Mem *mem)
:  {
: -	mem->u.u = (uint64_t)mem->u.b;
: +	uint64_t u = (uint64_t)mem->u.b;
: +	mem->u.u = u;
:  	mem->flags = MEM_UInt;
:  	mem->field_type = FIELD_TYPE_UNSIGNED;
:  	return 0;
: @@ -1599,7 +1600,7 @@ mem_shift_left(const struct Mem *left, const struct
: Mem *right,
:  		result->u.i = a >= 0 ? 0 : -1;
:  	else if (b < 0)
:  		result->u.i = a >> -b;
: -	else if (b > 64)
: +	else if (b >= 64)
:  		result->u.i = 0;
:  	else
:  		result->u.i = a << b;
: @@ -1621,7 +1622,7 @@ mem_shift_right(const struct Mem *left, const struct
: Mem *right,
:  		result->u.i = 0;
:  	else if (b < 0)
:  		result->u.i = a << -b;
: -	else if (b > 64)
: +	else if (b >= 64)
:  		result->u.i = a >= 0 ? 0 : -1;
:  	else
:  		result->u.i = a >> b;
: --
: 2.25.1



      reply	other threads:[~2021-04-22 23:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19 16:03 Mergen Imeev via Tarantool-patches
2021-04-22 23:12 ` Timur Safin via Tarantool-patches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='002201d737cc$f6d6fe60$e484fb20$@tarantool.org' \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tsafin@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/1] Fix SQL MEM-related warnings' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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