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 5C9B36EC5F; Thu, 15 Apr 2021 03:51:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5C9B36EC5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618447903; bh=4qqLAi9oCJeMoV0W+49T2i4nszbEdQyefdKcj5Z2PHo=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=bHNrk+dEUYoA7Luf1MD1AuZjEHSsrpOuOyweswSX4jjp00qB/wQTChP1FUr8XjwOr JnOA+cWS+/jwxRLGfsPyqobvNJ8CH4HRSVz70qXXHJfNhSLsSKZWwVKewMuTTGAuL+ oFpQ+WcCwN8AHT7ilv8G40mzkvqVnMtzPZ6Sopyo= Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [94.100.177.104]) (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 A00166EC5F for ; Thu, 15 Apr 2021 03:51:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A00166EC5F Received: by smtp44.i.mail.ru with esmtpa (envelope-from ) id 1lWqEP-0003sL-Vi; Thu, 15 Apr 2021 03:51:42 +0300 Date: Thu, 15 Apr 2021 03:51:40 +0300 To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Message-ID: <20210415005140.GA384863@tarantool.org> References: <326fac6c97ae260b32be9987e48e3381c600ba9c.1618000037.git.imeevma@gmail.com> <90cf544d-5188-ed34-face-15c231de09d1@tarantool.org> <20210414015548.GA185092@tarantool.org> <45bbd917-e5c9-1bf6-d621-8b5f80fd7d1b@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <45bbd917-e5c9-1bf6-d621-8b5f80fd7d1b@tarantool.org> X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E748094FADAEB10E66ADA4C48BE3C291E66DA182A05F538085040A8D1D7FF76073013C1063FA77B07CB1C4FD0F1CD35E25DF67D3F414AC27FAF02 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72424932217190DC2EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063770519A3AF4A224F58638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2ACE65CA83AF4477BEF19631A9F8A915B2AAFC1FEE5B068F7D2E47CDBA5A96583C09775C1D3CA48CFCA5A41EBD8A3A0199FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3CA5A41EBD8A3A0199FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE7711DDB4AE5B425DBD32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED6299176DF2183F8FC7C01E31B1F3D65882B1CD04E86FAF290E2D7E9C4E3C761E06A71DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C3E0287E8A3902ECA435872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4AD48C8163CD7E2ABE71C98BA224982BC1D X-C1DE0DAB: 0D63561A33F958A57F11C9B36D50B3B91B7F5A1496437A0227F2221FE6172416D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3472E5ECC12A9739C1AABD78B0E0DEE49EA54A0BA8A901E37125C37A21C54D915909F767A23EE824961D7E09C32AA3244CE770C4AFE131D5E830882F712E27708F39C99C45E8D137E9729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojrcJA+pXcDukdlns/zFDlzQ== X-Mailru-Sender: 5C3750E245F362008BC1685FEC6306EDF524FEE22FCC5A04C1063FA77B07CB1CF43CCAED39DA92F15105BD0848736F9966FEC6BF5C9C28D97E07721503EA2E00ED97202A5A4E92BF7402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v5 51/52] sql: introduce mem_get_bytes_len() 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: Mergen Imeev Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thank you for the review! My answer and diff below. On Thu, Apr 15, 2021 at 02:21:20AM +0200, Vladislav Shpilevoy wrote: > Thanks for the patch! > > > diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h > > index e7612fe7e..a67345fbd 100644 > > --- a/src/box/sql/mem.h > > +++ b/src/box/sql/mem.h > > @@ -870,6 +870,20 @@ mem_get_bin(const struct Mem *mem, const char **s); > > int > > mem_get_bytes_len(const struct Mem *mem, uint32_t *len); > > > > +/** > > + * Return length of value for MEM of STRING or VARBINARY type. This function is > > + * not safe since there is no proper processing in case mem_get_bytes_len() > > + * return an error. In this case this function returns 0. > > + */ > > +static inline int > > +mem_len_unsafe(const struct Mem *mem) > > +{ > > + uint32_t len; > > + if (mem_get_bytes_len(mem, &len) != 0) > > For the sake of consistency the safe function should be called > simply mem_len() IMO. > Fixed. > > + return 0; > > + return len; > > +} Diff: diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c index 6edf3f9d5..af760f236 100644 --- a/src/box/sql/mem.c +++ b/src/box/sql/mem.c @@ -1166,7 +1166,7 @@ mem_get_bin(const struct Mem *mem, const char **s) } int -mem_get_bytes_len(const struct Mem *mem, uint32_t *len) +mem_len(const struct Mem *mem, uint32_t *len) { if ((mem->flags & (MEM_Str | MEM_Blob)) == 0) return -1; diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h index a67345fbd..8e4b9f11a 100644 --- a/src/box/sql/mem.h +++ b/src/box/sql/mem.h @@ -868,18 +868,18 @@ mem_get_bin(const struct Mem *mem, const char **s); * not changed. */ int -mem_get_bytes_len(const struct Mem *mem, uint32_t *len); +mem_len(const struct Mem *mem, uint32_t *len); /** * Return length of value for MEM of STRING or VARBINARY type. This function is - * not safe since there is no proper processing in case mem_get_bytes_len() - * return an error. In this case this function returns 0. + * not safe since there is no proper processing in case mem_len() return an + * error. In this case this function returns 0. */ static inline int mem_len_unsafe(const struct Mem *mem) { uint32_t len; - if (mem_get_bytes_len(mem, &len) != 0) + if (mem_len(mem, &len) != 0) return 0; return len; }