From owner-svn-src-projects@freebsd.org Tue May 21 06:00:15 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E7C9F15A3F36 for ; Tue, 21 May 2019 06:00:14 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1284076C16; Tue, 21 May 2019 06:00:13 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x4L606Zr031016 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 21 May 2019 09:00:09 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x4L606Zr031016 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x4L606Un031014; Tue, 21 May 2019 09:00:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 21 May 2019 09:00:06 +0300 From: Konstantin Belousov To: Conrad Meyer Cc: Alan Somers , src-committers , svn-src-projects@freebsd.org Subject: Re: svn commit: r348007 - projects/fuse2/lib/libc/gen Message-ID: <20190521060006.GV2748@kib.kiev.ua> References: <201905201936.x4KJaaIC023310@repo.freebsd.org> <20190520202210.GT2748@kib.kiev.ua> <20190520205057.GU2748@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 May 2019 06:00:15 -0000 On Mon, May 20, 2019 at 03:17:05PM -0700, Conrad Meyer wrote: > On Mon, May 20, 2019 at 1:51 PM Konstantin Belousov 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.