From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 2241445C304 for ; Fri, 11 Dec 2020 13:04:11 +0300 (MSK) Received: by mail-lf1-f65.google.com with SMTP id a9so12569229lfh.2 for ; Fri, 11 Dec 2020 02:04:10 -0800 (PST) Date: Fri, 11 Dec 2020 13:04:08 +0300 From: Cyrill Gorcunov Message-ID: <20201211100408.GC544004@grain> References: <20201210161832.729439-1-gorcunov@gmail.com> <20201210161832.729439-2-gorcunov@gmail.com> <02c6bfc0-ceb1-c1bc-5d8b-2450dbc082bc@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <02c6bfc0-ceb1-c1bc-5d8b-2450dbc082bc@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v4 1/4] util: introduce strlcpy helper List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Serge Petrenko Cc: Mons Anderson , tml , Vladislav Shpilevoy On Fri, Dec 11, 2020 at 10:58:21AM +0300, Serge Petrenko wrote: > > > +size_t > > > +strlcpy(char *dst, const char *src, size_t size) > > > +{ > > > +=A0=A0=A0 size_t src_len =3D strlen(src); > > > +=A0=A0=A0 if (size) { >=20 >=20 > One nit: we usually use `if(smth)` for boolean values only. >=20 > For integer values please use the explicit variant: `if(size !=3D 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 !=3D [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 :)