From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id BD78C6EC5E; Fri, 23 Apr 2021 02:12:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BD78C6EC5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1619133163; bh=JeEITSaZicHCiMI+0aULNvnH5S9R1X4EmyDWrwRgW1E=; h=To:Cc:References:In-Reply-To:Date:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=t0W7eZm1kSjSPC1cKiqJurz83bFH3feGiwHpir+SfkulCyKGFH4tcNjHhFnLqYvhD xYBAlEBumpOY8Qr4BqDCxAQZlw2FDUrLTNGccNIENeAb3IMglDhbTrjSqiFQxWR1D1 TFI1wC4OMip5MFs+jj9TjTGW6DeQNYMp8nwgEwqM= Received: from smtp43.i.mail.ru (smtp43.i.mail.ru [94.100.177.103]) (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 5F10B6EC5E for ; Fri, 23 Apr 2021 02:12:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5F10B6EC5E Received: by smtp43.i.mail.ru with esmtpa (envelope-from ) id 1lZiUz-0000aj-Ll; Fri, 23 Apr 2021 02:12:42 +0300 To: Cc: References: <6c835ab6030cd1c20095a36d136b13dacd40f82f.1618848143.git.imeevma@gmail.com> In-Reply-To: <6c835ab6030cd1c20095a36d136b13dacd40f82f.1618848143.git.imeevma@gmail.com> Date: Fri, 23 Apr 2021 02:12:28 +0300 Message-ID: <002201d737cc$f6d6fe60$e484fb20$@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQHU5/3ikSreDYi4XLzzr2TPKuebF6rFyVAg Content-Language: ru X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9203E2ABA940B7548DB5D504FB17EC32432A3176CEA2677EC182A05F5380850401C4AA4F008F7C31D6E7BABFF0C3ACE31CE716825BD6BE7DEF9FDF4DFE7B0E905 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D3E352D4AD7EBF54EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378997215BCAA11D778638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2825CBA94D62513CE7D6BAC9CE1D0A2C4E2F41FD49071CA2BD2E47CDBA5A96583C09775C1D3CA48CF4964A708C60C975A117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE7820CF4CC0E318EFB9FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE7112AE74C7C989D437B076A6E789B0E97A8DF7F3B2552694A1E7802607F20496D49FD398EE364050F140C956E756FBB7A4DB3626BA78294CCB3661434B16C20AC78D18283394535A9E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8BCD7FADA94ADF7EACEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4ADC71662652165D925DB62D1679CB7BD92 X-C1DE0DAB: 0D63561A33F958A5F87BF46829D0AFE7D3A1D7A0AB03D43104CA784F1818336ED59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3453741B480A6503C39DDBBD89C9B08354B49ADCBEBBF49B32422AD7258FDCB4F14F3C57909EE580041D7E09C32AA3244C4E40BE9519A2FC3EB72FD5E2A4470786250262A5EE9971B0729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMA4lh0BuVjOjTu5pQZQ0NA== X-Mailru-Sender: 6CA451E36783D721CBEA96CEA26D325D85EBA55F8782B538695FF57579F46AB7B7CBEF92542CD7C82F97C478340294DCC77752E0C033A69E0F0C7111264B8915FF1320A92A5534336C18EFA0BB12DBB0 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 1/1] Fix SQL MEM-related warnings X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Timur Safin via Tarantool-patches Reply-To: Timur Safin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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 : 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