From owner-svn-src-head@FreeBSD.ORG Fri Mar 13 10:26:36 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 84C2CE8F; Fri, 13 Mar 2015 10:26:36 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5A01B169; Fri, 13 Mar 2015 10:26:36 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id DBFCDB93C; Fri, 13 Mar 2015 06:26:34 -0400 (EDT) From: John Baldwin To: Ian Lepore Subject: Re: svn commit: r279932 - head/sys/vm Date: Fri, 13 Mar 2015 06:24:47 -0400 Message-ID: <29142844.yUiOLJLpmU@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-STABLE; KDE/4.14.2; amd64; ; ) In-Reply-To: <1426202691.6265.4.camel@freebsd.org> References: <201503121806.t2CI6VSU034853@svn.freebsd.org> <1426202691.6265.4.camel@freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 13 Mar 2015 06:26:35 -0400 (EDT) Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , Ryan Stone X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2015 10:26:36 -0000 On Thursday, March 12, 2015 05:24:51 PM Ian Lepore wrote: > On Thu, 2015-03-12 at 17:02 -0400, Ryan Stone wrote: > > On Thu, Mar 12, 2015 at 2:06 PM, Ian Lepore wrote: > > > > > Nullterminate strings returned via sysctl. > > > > > > PR: 195668 > > > > > > > To quote the manpage: > > > > > The *sbuf* family of functions allows one to safely > > > allocate, construct and release bounded null-terminated > > > strings in kernel space. > > > > IMO the sbuf API is broken if we have to explicitly null-terminate the > > string ourselves. > > If we want the nullterm to be counted in the length of data in the > buffer (and thus get transmitted back across the syscall boundary) we > need to put an explicit counted nullterm byte into the buffer. > > I had started down the path of making that (counting the nullterm byte > as part of the data in the buffer) a feature of sbuf that you could set > with a flag, but then whoever added sbuf_new_for_sysctl() didn't > propagate the flags field through the new function and I decided to not > go off into the weeds making a new flavor of that takes flags. One suggestion would be to consider using '\0' for a nul character instead of a bare 0. To me that communicates the intention more clearly to the reader. (One of the things I did not like about C++ < C++11 was the use of 0 for NULL. I much prefer nullptr and NULL in C over bare 0's for pointers for similar clarity reasons.) -- John Baldwin