From owner-svn-src-all@FreeBSD.ORG Fri Mar 13 16:51:07 2015 Return-Path: Delivered-To: svn-src-all@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 5D3BBFD0; Fri, 13 Mar 2015 16:51:07 +0000 (UTC) Received: from relay.mailchannels.net (aso-006-i437.relay.mailchannels.net [23.91.64.118]) by mx1.freebsd.org (Postfix) with ESMTP id CD5D31EE; Fri, 13 Mar 2015 16:51:05 +0000 (UTC) X-Sender-Id: duocircle|x-authuser|hippie Received: from smtp7.ore.mailhop.org (ip-10-33-12-218.us-west-2.compute.internal [10.33.12.218]) by relay.mailchannels.net (Postfix) with ESMTPA id B4FF01D0DD0; Fri, 13 Mar 2015 16:14:50 +0000 (UTC) X-Sender-Id: duocircle|x-authuser|hippie Received: from smtp7.ore.mailhop.org (smtp7.ore.mailhop.org [10.83.15.107]) (using TLSv1 with cipher DHE-RSA-AES256-SHA) by 0.0.0.0:2500 (trex/5.4.8); Fri, 13 Mar 2015 16:14:51 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: duocircle|x-authuser|hippie X-MailChannels-Auth-Id: duocircle X-MC-Loop-Signature: 1426263290862:1414706375 X-MC-Ingress-Time: 1426263290862 Received: from c-73-34-117-227.hsd1.co.comcast.net ([73.34.117.227] helo=ilsoft.org) by smtp7.ore.mailhop.org with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.82) (envelope-from ) id 1YWSEZ-0002Kr-MI; Fri, 13 Mar 2015 16:14:47 +0000 Received: from revolution.hippie.lan (revolution.hippie.lan [172.22.42.240]) by ilsoft.org (8.14.9/8.14.9) with ESMTP id t2DGERPE016522; Fri, 13 Mar 2015 10:14:28 -0600 (MDT) (envelope-from ian@freebsd.org) X-Mail-Handler: DuoCircle Outbound SMTP X-Originating-IP: 73.34.117.227 X-Report-Abuse-To: abuse@duocircle.com (see https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information for abuse reporting information) X-MHO-User: U2FsdGVkX1+Now8qP+CeloYSqrfdJgAx Message-ID: <1426263267.91779.19.camel@freebsd.org> Subject: Re: svn commit: r279932 - head/sys/vm From: Ian Lepore To: John Baldwin Date: Fri, 13 Mar 2015 10:14:27 -0600 In-Reply-To: <29142844.yUiOLJLpmU@ralph.baldwin.cx> References: <201503121806.t2CI6VSU034853@svn.freebsd.org> <1426202691.6265.4.camel@freebsd.org> <29142844.yUiOLJLpmU@ralph.baldwin.cx> Content-Type: text/plain; charset="us-ascii" X-Mailer: Evolution 3.12.10 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-AuthUser: hippie Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , Ryan Stone X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2015 16:51:07 -0000 On Fri, 2015-03-13 at 06:24 -0400, John Baldwin wrote: > 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.) > I have waffled back and forth between preferring 0 or '\0' for 30 years, I just seem to go through phases with nullterm expression. In general I'm glad I got called away to an onsite meeting yesterday and didn't get far with these changes, because the more I think about it, the less satisfied I am with this expedient fix. The other fix I started on, where a new SBUF_COUNTNUL flag can be set to inform the sbuf_finish() code that you want the terminating nul counted in the data length just feels like a better fit for the overall "automaticness" of how the sbuf stuff works. -- Ian