Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Feb 2015 09:33:31 +0800
From:      Erich Dollansky <erichsfreebsdlist@alogt.com>
To:        John-Mark Gurney <jmg@funkthat.com>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: top, fixed buffer length in utils.c
Message-ID:  <20150205093331.1bb876e1@B85M-HD3-0.alogt.com>
In-Reply-To: <20150204183548.GA27763@funkthat.com>
References:  <20150201175159.7fa88d16@B85M-HD3-0.alogt.com> <20150203003307.GG27103@funkthat.com> <20150203200135.57c8c236@B85M-HD3-0.alogt.com> <20150204074235.GX27103@funkthat.com> <20150204170947.17764dff@B85M-HD3-0.alogt.com> <20150204183548.GA27763@funkthat.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

On Wed, 4 Feb 2015 10:35:48 -0800
John-Mark Gurney <jmg@funkthat.com> wrote:

> Erich Dollansky wrote this message on Wed, Feb 04, 2015 at 17:09
> +0800:
> > Hi,
> > 
> > On Tue, 3 Feb 2015 23:42:35 -0800
> > John-Mark Gurney <jmg@funkthat.com> wrote:
> > 
> > > Ok, I've generated this patch:
> > > Index: utils.c
> > > ===================================================================
> > > --- utils.c	(revision 277938)
> > > +++ utils.c	(working copy)
> > > @@ -58,6 +58,7 @@ char *str;
> > >  				 * ever convert will be 2^32-1,
> > > which is 10
> > >  				 * digits.
> > >  				 */
> > > +_Static_assert(sizeof(int) <= 4, "buffer too small for this sized
> > > int"); 
> > >  char *itoa(val)
> > >  
> > Wait, shouldn't it the other way around? It will break when sizeof
> > (int) is greater than 4?
> 
> No, asserts trigger when the statement is false... I verified this
> by changing 4 to 2 and seeing that it failed (triggered) to compile...
> 
so, I learned something new with FreeBSD. I never use them as we have a
set of macros from a time long before these kind of macros came up and
never changed. You know, never change w winning team.

Erich



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150205093331.1bb876e1>