From: Mergen Imeev via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v5 51/52] sql: introduce mem_get_bytes_len() Date: Thu, 15 Apr 2021 03:51:40 +0300 [thread overview] Message-ID: <20210415005140.GA384863@tarantool.org> (raw) In-Reply-To: <45bbd917-e5c9-1bf6-d621-8b5f80fd7d1b@tarantool.org> 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; }
next prev parent reply other threads:[~2021-04-15 0:51 UTC|newest] Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <cover.1618000036.git.imeevma@gmail.com> 2021-04-09 20:53 ` [Tarantool-patches] [PATCH v5 41/52] sql: introduce mem_to_number() Mergen Imeev via Tarantool-patches 2021-04-13 23:25 ` Mergen Imeev via Tarantool-patches 2021-04-09 20:53 ` [Tarantool-patches] [PATCH v5 42/52] sql: introduce mem_to_str() and mem_to_str0() Mergen Imeev via Tarantool-patches 2021-04-13 22:58 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-13 23:41 ` Mergen Imeev via Tarantool-patches 2021-04-09 20:53 ` [Tarantool-patches] [PATCH v5 43/52] sql: introduce mem_cast_explicit() Mergen Imeev via Tarantool-patches 2021-04-13 22:59 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-14 0:01 ` Mergen Imeev via Tarantool-patches 2021-04-09 20:53 ` [Tarantool-patches] [PATCH v5 44/52] sql: introduce mem_cast_implicit() Mergen Imeev via Tarantool-patches 2021-04-13 22:59 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-14 0:05 ` Mergen Imeev via Tarantool-patches 2021-04-09 20:53 ` [Tarantool-patches] [PATCH v5 45/52] sql: introduce mem_get_int() Mergen Imeev via Tarantool-patches 2021-04-13 23:01 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-14 0:28 ` Mergen Imeev via Tarantool-patches 2021-04-14 1:17 ` Mergen Imeev via Tarantool-patches 2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 46/52] sql: introduce mem_get_uint() Mergen Imeev via Tarantool-patches 2021-04-13 23:04 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-14 0:39 ` Mergen Imeev via Tarantool-patches 2021-04-14 1:21 ` Mergen Imeev via Tarantool-patches 2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 47/52] sql: introduce mem_get_double() Mergen Imeev via Tarantool-patches 2021-04-13 23:04 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-14 1:00 ` Mergen Imeev via Tarantool-patches 2021-04-15 0:17 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-15 0:46 ` Mergen Imeev via Tarantool-patches 2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 48/52] sql: introduce mem_get_bool() Mergen Imeev via Tarantool-patches 2021-04-13 23:04 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-14 1:29 ` Mergen Imeev via Tarantool-patches 2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 49/52] sql: introduce mem_get_str0() and mem_as_str0() Mergen Imeev via Tarantool-patches 2021-04-13 23:06 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-14 1:43 ` Mergen Imeev via Tarantool-patches 2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 50/52] sql: introduce mem_get_bin() Mergen Imeev via Tarantool-patches 2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 51/52] sql: introduce mem_get_bytes_len() Mergen Imeev via Tarantool-patches 2021-04-13 23:06 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-14 1:55 ` Mergen Imeev via Tarantool-patches 2021-04-15 0:21 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-15 0:51 ` Mergen Imeev via Tarantool-patches [this message] 2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 52/52] sql: introduce mem_get_agg() Mergen Imeev via Tarantool-patches
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=20210415005140.GA384863@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imeevma@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v5 51/52] sql: introduce mem_get_bytes_len()' \ /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