From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.cs.ucla.edu (mail.cs.ucla.edu [131.179.128.66]) by sourceware.org (Postfix) with ESMTPS id 9E97B3858D20 for ; Fri, 21 Apr 2023 19:00:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E97B3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cs.ucla.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.ucla.edu Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 098983C097AFA; Fri, 21 Apr 2023 12:00:56 -0700 (PDT) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id r5266vTrSLDq; Fri, 21 Apr 2023 12:00:55 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id BFB7A3C097AFC; Fri, 21 Apr 2023 12:00:55 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu BFB7A3C097AFC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1682103655; bh=MTEMH1jYQEr4lSeWpbOdLGX1mRC7zXq9CLtjGESKnb0=; h=Message-ID:Date:MIME-Version:To:From; b=MBp47mWJDkFsf3odzN1TeyaqqCKwERC4swd0Z1E4+lNqjh1JHU/tSwA+0iu1jzh/F 0bBW4pYbtieIZpG3CHEhTNDzTavtjwuYR/INgfSD9lji1xTIS4wDCUx25G3SDLv0pk fa7VWyYGMHCPvtYolMsBgdDDa/ngUVCCBIodyx1vXG1HaFdmySqcvsc0MBejufCm6o x0QLxZSgvgYuLvFU9WJIn50DWyvchIspQs8mc4LYbjQ9zrV29TnvVeFL254udzUBMR Cxp8BJ72dGMWhkbbQP6Fz2cq+ArfkuH/Kn4RA5qJOaFHZpUBKYc8cL76rEPdeVsNkI eHFsi1RAZD5jw== X-Virus-Scanned: amavisd-new at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 4-0TgcUi-JNc; Fri, 21 Apr 2023 12:00:55 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id 9CBE83C097AFA; Fri, 21 Apr 2023 12:00:55 -0700 (PDT) Message-ID: <5e68a408-6351-ad94-34fc-f14b88876d40@cs.ucla.edu> Date: Fri, 21 Apr 2023 12:00:55 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH 1/2] Implement strlcpy and strlcat [BZ #178] Content-Language: en-US To: Florian Weimer Cc: libc-alpha@sourceware.org References: <3e699937-2b0d-7218-3f97-ab54154806c1@cs.ucla.edu> <87bkjjgeol.fsf@oldenburg.str.redhat.com> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <87bkjjgeol.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,JMQ_SPF_NEUTRAL,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2023-04-20 01:07, Florian Weimer wrote: > * Paul Eggert: > >>> +extern __typeof (strlcpy) __strlcpy; >>> +libc_hidden_proto (__strlcpy) >>> +extern __typeof (strlcat) __strlcat; >>> +libc_hidden_proto (__strlcat) >> >> Glibc shouldn't call these functions internally, so let's not export >> them to elsewhere in glibc. > > strlcpy looks like it could be called for implementing %s in snprintf. > That seems like a reasonable optimization. No, because strlcpy must return the length of the source even when it's longer than INT_MAX. (This is a botch in the spec which we apparently cannot fix.) So there's no way snprintf could use strlcpy without hurting worst-case performance. > Less sure about strlcat, we could drop the PLT avoidance for that, I > assume. Let's drop it for both. If there's ever a real need for either (which I doubt) we can add it as needed. > I expect someone to rewrite this using word-size accesses fairly soon. That would be headed in the wrong direction. We should not waste time trying to optimize these functions' copying actions, as the destinations are invariably so small that our attempts to "optimize" will likely hurt performance.