Date: Tue, 17 Feb 2015 16:52:21 -0500 From: John Baldwin <jhb@freebsd.org> To: freebsd-stable@freebsd.org Cc: John-Mark Gurney <jmg@funkthat.com>, Erich Dollansky <erichsfreebsdlist@alogt.com> Subject: Re: top, fixed buffer length in utils.c Message-ID: <201502171652.21779.jhb@freebsd.org> In-Reply-To: <20150212202245.GE1953@funkthat.com> References: <20150201175159.7fa88d16@B85M-HD3-0.alogt.com> <20150212163945.36aa9971@B85M-HD3-0.alogt.com> <20150212202245.GE1953@funkthat.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <jmg@funkthat.com> 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 <bob@immure.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502171652.21779.jhb>