Date: Tue, 21 May 2019 09:00:06 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Conrad Meyer <cem@freebsd.org> Cc: Alan Somers <asomers@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-projects@freebsd.org Subject: Re: svn commit: r348007 - projects/fuse2/lib/libc/gen Message-ID: <20190521060006.GV2748@kib.kiev.ua> In-Reply-To: <CAG6CVpVZCVDdyR%2BBOXfV4Z98_hEP8UbE3yvpUVfZGQPiUU_q5w@mail.gmail.com> References: <201905201936.x4KJaaIC023310@repo.freebsd.org> <20190520202210.GT2748@kib.kiev.ua> <CAOtMX2i6Z7=QPG3LNBdGLDKE3Gm-JJGQ_jzdAuQPF=JFn9e9yQ@mail.gmail.com> <20190520205057.GU2748@kib.kiev.ua> <CAG6CVpVZCVDdyR%2BBOXfV4Z98_hEP8UbE3yvpUVfZGQPiUU_q5w@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, May 20, 2019 at 03:17:05PM -0700, Conrad Meyer wrote: > On Mon, May 20, 2019 at 1:51 PM Konstantin Belousov <kostikbel@gmail.com> wrote: > > > > On Mon, May 20, 2019 at 02:43:36PM -0600, Alan Somers wrote: > > > True, but I though that strlen would be more readable. Clang is smart > > > enough to realize that strlen's argument is a constant and omit the > > > call to strlen, so that's what I went with. Is there any other reason > > > to prefer sizeof() - 1 ? > > > > The reason is that it would also work for not so smart compiler, or with > > a smart compiler after we finally turn on -ffreestanding for libc, as it > > ought to be. > > If we did that, it might make sense to implement strlen() as a macro > that did essentially the same thing using __builtin_strlen() (and > __builtin_constant_p, if necessary) extensions. It is too far-reaching to request to hack strlen() to use gcc extension in response to a simple request to use sizeof() in appropriate situation.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190521060006.GV2748>