[PATCH 3/8] Enhance source position implementation.

Jon Loeliger jdl at freescale.com
Thu Sep 25 03:17:35 EST 2008


On Wed, 2008-09-24 at 12:07 -0500, Scott Wood wrote:

> > +char *
> > +srcpos_string(srcpos *pos)
> > +{
> > +#	define POS_BUF_SIZE	(100)
> 
> Local #defines make $YOUTHFUL_DEITY_OFFSPRING cry (and the whitespace 
> after the # doesn't help).  Declare a "const int", or just use sizeof(buf).

Sigh.

> 
> Seems a little elaborate;

...and yet clear.

>  are there cases where reporting the 
> line/column of the first character of the token is not clear?

Yes.

> > +	return strdup(buf);
> 
> Why not just dynamically allocate the buffer in the first place?  Or if 
> you care about the memory wastage (which you probably don't, given that 
> you just leak the allocated string in the callers in later patches), 
> make this function take a FILE * to output to, rather than return an 
> allocated string.

Well, it was really a more general formatting routine.
It may not always directly be output directly to a FILE.

So, maybe there is some room for improvement or optimization
in the future...

jdl





More information about the devicetree-discuss mailing list