Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp105614ybi; Fri, 14 Jun 2019 19:59:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgqDX6Xv/VDE0nfofhSDwszqqW3yhuHCGvFQuhKdYWSoZCJ6oZ/CXibMd6fjA00QjHlXzO X-Received: by 2002:a65:5347:: with SMTP id w7mr38297487pgr.375.1560567562658; Fri, 14 Jun 2019 19:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560567562; cv=none; d=google.com; s=arc-20160816; b=tybeQJtZWMFPcCIyNybiE8mjJfZEuZ1f3TcuvYGIsngfGMs8J2izD08BcNdRf+3hGk jJMSeukdEelqr8H03Cc9drbsansU+8cO4ZodqqJzb89K1PFtdmQu9nq2Qop/+8iML7M5 ntdLJ+jgiEX4WKF7yc81ztcMRjJiW8fvBLr4GRjs7f/4tuI+HnjL1G/ucp7D4bKtGyhi RD/K6arUZfA2v59ljtSbyT8ZXSkdvzzJV50aA6JyeJbr8/MN6kaQeTCmaYEWPBg34qU2 4U7Rff+IZmYeAsrJDu828YCQMT872sCmfphJtKGnqTbVjdF1gQO56AdYH2d+aYFEijHG Updg== 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=pSTWYHAyPR38omPLQf+O1wCN+KfuyAs84FRBqk6cG2Q=; b=Ezt5tgXDDTzu1FXcQZjwBuACMuIZ50bo2ap3RuC32N4xnIGVo0vySMXJe6KiWX+MpC aGnJYa84vcp7T7dIbcT3rjtZrUnICH3tCiJipO4uLR0OvttLogkxIkN68P6jeW3Mj/BK H11BaBLJ0G1QowIgJ+BgPv55kPn/Yj1U56rqwXJptszOQZXpfVyLusdaRxp8gSSlxxF+ cyO5Poulhy75Q+QWKbk+86UM97wrrcLHCeh2bLp+jXQEpejKTEFoVRM9yekJer8qk2Hf ZdYiLaw3HyFrnrgVvwZoMLWpmNs5jRoXv3NNhaipHgivUjgVI8PtSSVk20G8tD0OyLL/ tvHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j62si4075208pgc.71.2019.06.14.19.59.07; Fri, 14 Jun 2019 19:59:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbfFOC62 (ORCPT + 99 others); Fri, 14 Jun 2019 22:58:28 -0400 Received: from smtprelay0113.hostedemail.com ([216.40.44.113]:34681 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725825AbfFOC62 (ORCPT ); Fri, 14 Jun 2019 22:58:28 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay02.hostedemail.com (Postfix) with ESMTP id C0F2540EE; Sat, 15 Jun 2019 02:58:26 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::,RULES_HIT:41:355:379:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:1981:2194:2199:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3871:3874:4250:4321:5007:6119:7903:8660:10004:10400:10848:11232:11658:11914:12296:12740:12760:12895:13069:13148:13161:13229:13230:13311:13357:13439:14096:14097:14181:14659:14721:21080:21433:21627:30054:30060:30090:30091,0,RBL:23.242.70.174:@perches.com:.lbl8.mailshell.net-62.8.0.180 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: waves33_4975be92db727 X-Filterd-Recvd-Size: 2217 Received: from XPS-9350 (cpe-23-242-70-174.socal.res.rr.com [23.242.70.174]) (Authenticated sender: joe@perches.com) by omf04.hostedemail.com (Postfix) with ESMTPA; Sat, 15 Jun 2019 02:58:24 +0000 (UTC) Message-ID: <75c8f066c3aa2e20db2e1554a4d28c20b2952724.camel@perches.com> Subject: Re: [PATCH 1/3] lib/vsprintf: add snprintf_noterm From: Joe Perches To: "Yan, Zheng" , Jeff Layton Cc: Linux Kernel Mailing List , ceph-devel , Andrew Morton , Ilya Dryomov , Zheng Yan , Sage Weil , agruenba@redhat.com Date: Fri, 14 Jun 2019 19:58:23 -0700 In-Reply-To: References: <20190614134625.6870-1-jlayton@kernel.org> <20190614134625.6870-2-jlayton@kernel.org> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.5-0ubuntu0.18.10.1 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 Sat, 2019-06-15 at 10:41 +0800, Yan, Zheng wrote: > On Fri, Jun 14, 2019 at 9:48 PM Jeff Layton wrote: > > The getxattr interface returns a length after filling out the value > > buffer, and the convention with xattrs is to not NULL terminate string > > data. > > > > CephFS implements some virtual xattrs by using snprintf to fill the > > buffer, but that always NULL terminates the string. If userland sends > > down a buffer that is just the right length to hold the text without > > termination then we end up truncating the value. > > > > Factor the formatting piece of vsnprintf into a separate helper > > function, and have vsnprintf call that and then do the NULL termination > > afterward. Then add a snprintf_noterm function that calls the new helper > > to populate the string but skips the termination. Is this function really necessary enough to add the additional stack use to the generic case? Why not add have this function call vsnprintf and then terminate the string separately?