[Tarantool-patches] [PATCH 4/5] decimal: introduce decimal_to_string

Sergey Ostanevich sergos at tarantool.org
Sun Aug 1 20:06:25 MSK 2021


Hi! Thanks for updates!

> 
> It is in the commit title already. I don't want to duplicate the title
> in the message.
> 

Sure, just missed it. 

>>> diff --git a/src/lib/core/decimal.c b/src/lib/core/decimal.c
>>> index 4befbda37..6d2ccb96f 100644
>>> --- a/src/lib/core/decimal.c
>>> +++ b/src/lib/core/decimal.c
>>> @@ -175,6 +175,14 @@ decimal_str(const decimal_t *dec)
>>> 	return buf;
>>> }
>>> 
>>> +void
>>> +decimal_to_string(const decimal_t *dec, char *str)
>>> +{
>>> +	char *tmp = decNumberToString(dec, str);
>>> +	assert(str == tmp);
>> 
>> Why? The decToString() doesn't touch original string pointer, working on
>> a local copy.
> 
> Yes, this is why there is the assertion. Also to be consistent with
> decimal_str() which has the same assert.
> 

I really doubt we need to assert something that has no chance to be wrong.

Anyways, LGTM.

Sergos



More information about the Tarantool-patches mailing list