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 5825F6EC5F; Mon, 19 Apr 2021 19:03:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5825F6EC5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618848225; bh=DK/Q1aungaXvJztVPpw/DW12P5wK9xdojM2NlqMRyxk=; h=To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=hGYdEJIred6a7pltZcs+0N/la+Bnd0Fi3oydrC2snrmRPV63YrAOOO5vu1J1Kypuq rPERVnc9Q8WoYh6o+0T6Fl655fEFHTdNiJfwb3TGv7K0qhQEdDoO1qvPrvIyvD8naI SGXc/By55dAUzvgc7c9LEcmFFintx6STIM0np/Zs= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 D5D216EC5F for ; Mon, 19 Apr 2021 19:03:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D5D216EC5F Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lYWND-0003YC-1M; Mon, 19 Apr 2021 19:03:43 +0300 To: tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Mon, 19 Apr 2021 19:03:42 +0300 Message-Id: <6c835ab6030cd1c20095a36d136b13dacd40f82f.1618848143.git.imeevma@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E74800BD71C2E2CF43DDE8CBA234A641A13D4182A05F538085040023768D6B4C5E7B4D41442982D58F6E786EF50470C6EEE41FFFFF729B48B67A7 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE707BCAA832FAF0FF2C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE707BCAA832FAF0FF28F08D7030A58E5ADC58D69EE07B14084F39EFFDF887939037866D6147AF826D854D0737BE1C2D91BF24BEDA8C45B8C846F9789CCF6C18C3F8528715B7D10C86878DA827A17800CE784CEF0E7A50379599FA2833FD35BB23D9E625A9149C048EEB1593CA6EC85F86DC26CFBAC0749D213D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B4871F77D444DC01FA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB02EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE754A400A07F115C59731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C5C2F678D3BD5F52972440B8A0BF318F1D13D3B1F98CF32439C2B6934AE262D3EE7EAB7254005DCED556CBE7F905700A49510FB958DCE06DB6ED91DBE5ABE359ADBCB5631A0A9D21F1B2EFE7B39F7738393EDB24507CE13387DFF0A840B692CF8 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A9873270276D43348346BDB5BB5234AF46ED698D146AEE7AF19756F83851D63E155CDDDC09EADE1E1D7E09C32AA3244CD6271C193C2855EDF1DCEED4329EC457853296C06374E602729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojocJA+pXcDummZeX+jGIAlg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638227F10DF68F182036720BC1B16A522F51F83D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [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: Mergen Imeev via Tarantool-patches Reply-To: imeevma@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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