[Tarantool-patches] [PATCH v5 51/52] sql: introduce mem_get_bytes_len()

Mergen Imeev imeevma at tarantool.org
Thu Apr 15 03:51:40 MSK 2021


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;
 }


More information about the Tarantool-patches mailing list