[Tarantool-patches] [PATCH v4 1/4] util: introduce strlcpy helper

Cyrill Gorcunov gorcunov at gmail.com
Fri Dec 11 13:04:08 MSK 2020


On Fri, Dec 11, 2020 at 10:58:21AM +0300, Serge Petrenko wrote:
> > > +size_t
> > > +strlcpy(char *dst, const char *src, size_t size)
> > > +{
> > > +    size_t src_len = strlen(src);
> > > +    if (size) {
> 
> 
> One nit: we usually use `if(smth)` for boolean values only.
> 
> For integer values please use the explicit variant: `if(size != 0)`

Ouch, indeed. I'll force push an update once Vlad comment out
the series.

n.b. You know every time I see `if (x != [0|NULL])` statement
it driving me nuts: the language standart is pretty clear for
`if ()` statement and explains how it is evaluated and I always
wonder who exactly invented this explisit test for non-zero/nil?!
Now *every* if statement requires 5 additional symbols for simply
nothing :( I suspect the person who started to use this form
simply was not aware of the language standart.

Surely I try to follow current code style, just saying :)


More information about the Tarantool-patches mailing list