From owner-freebsd-stable@FreeBSD.ORG Tue Feb 17 22:39:39 2015 Return-Path: Delivered-To: freebsd-stable@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 BF09EAC0 for ; Tue, 17 Feb 2015 22:39:39 +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 9607EF3A for ; Tue, 17 Feb 2015 22:39:39 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id A3320B91F; Tue, 17 Feb 2015 17:39:37 -0500 (EST) From: John Baldwin To: freebsd-stable@freebsd.org Subject: Re: top, fixed buffer length in utils.c Date: Tue, 17 Feb 2015 16:52:21 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20140415; KDE/4.5.5; amd64; ; ) References: <20150201175159.7fa88d16@B85M-HD3-0.alogt.com> <20150212163945.36aa9971@B85M-HD3-0.alogt.com> <20150212202245.GE1953@funkthat.com> In-Reply-To: <20150212202245.GE1953@funkthat.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201502171652.21779.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 17 Feb 2015 17:39:37 -0500 (EST) Cc: John-Mark Gurney , Erich Dollansky X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Feb 2015 22:39:39 -0000 On Thursday, February 12, 2015 3:22:45 pm John-Mark Gurney wrote: > Erich Dollansky wrote this message on Thu, Feb 12, 2015 at 16:39 +0800: > > Hi, > > > > On Wed, 11 Feb 2015 19:39:24 -0800 > > John-Mark Gurney wrote: > > > > > Erich Dollansky wrote this message on Thu, Feb 12, 2015 at 09:13 > > > +0800: > > > > On Tue, 10 Feb 2015 17:14:41 -0600 > > > > Bob Willcox wrote: > > > > > > > > > On Mon, Feb 02, 2015 at 04:33:07PM -0800, John-Mark Gurney wrote: > > > > > > Erich Dollansky wrote this message on Sun, Feb 01, 2015 at 17:51 > > > > > > +0800: > > > > > > > > > > > > I guess adding: > > > > > > CTASSERT(sizeof(int) <= 4); > > > > > > > > > Feel free to submit a patch eliminating the size assumption... I'll > > > review and commit it if/when you do... > > > > > did you add > > > > CTASSERT(sizeof(int) <= 4); > > > > already? > > > > This would do as a message will popup when the problem finally arises. > > Similar... > > https://svnweb.freebsd.org/changeset/base/278560 Why not use sizeof(int) to size the array instead of adding the assert if you want it to really be future proof? Each byte will generate at most 3 decimal chars, so char buf[sizeof(int) * 3 + 1]; or some such (yes, this overestimates a bit). -- John Baldwin