Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1300922pxa; Sat, 15 Aug 2020 15:01:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlLcKEDBAWE/oXwyWRMSOSu3iWKzIhDr/DfBd9EMs8CSEGmOrxWaZCWrc42FIJtmM/wN5R X-Received: by 2002:a17:906:29d5:: with SMTP id y21mr8159182eje.131.1597528910767; Sat, 15 Aug 2020 15:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597528910; cv=none; d=google.com; s=arc-20160816; b=m0iLjdnCsc9PmgHMeXvCCleyeyjLcISpnikxJ2idCVjbWaioIhURjMlz3XWiX1+Rmg 6pnA/iq7eh/GCGH11IYPm8QA1PhzNt2xH98N5eG6VPhVLpFVNd9WcG1OTC0Sd8+eeT8m G9xjjE2NB7Rdj9sCkG8S2kjOdsaeMX/ksD/GWN6epGpGUXW1rNt2F/fGZdLqcfDKgWtY fu6FXYVD6+pt7MWHNNx3ytn6p8ruADOgpHyYFYmU8+BWiGDI3g8AcSPCzashjslotTEj WK74wgs5bEfgIfOP8akrDzBRe8eOBiacDH9PZhqh6HukxWG9FXZaiS3+SjUQ6qClstXv iLng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=plvWGv6nd9zcUlBySh/yFb002eDP0QZEJuCCBvvxP2A=; b=iqmy+OUO8+zCEjkFdlrNfXkbh0SFfdbTQek7hISxR7sUcLl8En5ecPl+ZMOcE/QW08 8i/OJHU33x33iiE91WdEauvAFABD8P29SPeqJ2m4HcHTIazS4NY8WWVUrl/hVgwlFITR T+XrNTrEGwVwBfAS89Q1njaEQCo4ohHgqiFvhSGZSxZBRQQuEoCrIFBRBi7/RWaIRAWq BcCfHktwEqBfhRBaRsoDq0pdkq+IfCNafKn4C8WTfZ15Uo0/4SzpOPNYicXlW52rP6rb eeE40HcBc+fEcWDLitsXAglZK29pPlahrdbuAA5GQ7lsLA9A/jSXryzzFAYhTsBovCDG qYSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si8157519edy.237.2020.08.15.15.01.28; Sat, 15 Aug 2020 15:01:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729496AbgHOV6B (ORCPT + 99 others); Sat, 15 Aug 2020 17:58:01 -0400 Received: from smtprelay0189.hostedemail.com ([216.40.44.189]:50018 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728964AbgHOV6A (ORCPT ); Sat, 15 Aug 2020 17:58:00 -0400 Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave01.hostedemail.com (Postfix) with ESMTP id 5BC0718041E63; Sat, 15 Aug 2020 00:52:04 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id 2CF8C18026226; Sat, 15 Aug 2020 00:52:04 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3868:3870:3871:3872:3874:4321:5007:6117:6119:6742:7875:10004:10400:10848:11026:11232:11473:11658:11914:12297:12346:12740:12760:12895:13069:13311:13357:13439:14659:14721:21080:21451:21627:21990:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: feast89_3216ee827001 X-Filterd-Recvd-Size: 2404 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Sat, 15 Aug 2020 00:52:01 +0000 (UTC) Message-ID: <562003af51ca0b08f2108147b8d6e75cec18f3fd.camel@perches.com> Subject: Re: [PATCH] lib/string.c: implement stpcpy From: Joe Perches To: Nick Desaulniers , Andrew Morton Cc: =?ISO-8859-1?Q?D=E1vid_Bolvansk=FD?= , Eli Friedman , stable@vger.kernel.org, Sami Tolvanen , Tony Luck , Yury Norov , Daniel Axtens , Arvind Sankar , Dan Williams , "Joel Fernandes (Google)" , Andy Shevchenko , Kees Cook , Alexandru Ardelean , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Date: Fri, 14 Aug 2020 17:52:00 -0700 In-Reply-To: <20200815002417.1512973-1-ndesaulniers@google.com> References: <20200815002417.1512973-1-ndesaulniers@google.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2020-08-14 at 17:24 -0700, Nick Desaulniers wrote: > LLVM implemented a recent "libcall optimization" that lowers calls to > `sprintf(dest, "%s", str)` where the return value is used to > `stpcpy(dest, str) - dest`. This generally avoids the machinery involved > in parsing format strings. [] > diff --git a/include/linux/string.h b/include/linux/string.h [] > @@ -31,6 +31,9 @@ size_t strlcpy(char *, const char *, size_t); > #ifndef __HAVE_ARCH_STRSCPY > ssize_t strscpy(char *, const char *, size_t); > #endif > +#ifndef __HAVE_ARCH_STPCPY > +extern char *stpcpy(char *__restrict, const char *__restrict__); Why use two different forms for __restrict and __restrict__? Any real reason to use __restrict__ at all? It's used nowhere else in the kernel. $ git grep -w -P '__restrict_{0,2}' scripts/genksyms/keywords.c: // According to rth, c99 defines "_Bool", __restrict", __restrict__", "restrict". KAO scripts/genksyms/keywords.c: { "__restrict__", RESTRICT_KEYW },