[1/5] dtc: Implement and use an xstrdup() function

David Gibson david at gibson.dropbear.id.au
Sat Oct 4 12:49:58 EST 2008


On Fri, Oct 03, 2008 at 12:17:27PM -0500, Jon Loeliger wrote:
> > Many places in dtc use strdup(), but none of them actually check the
> > return value to see if the implied allocation succeeded.  This is a
> > potential bug, which we fix in the patch below by replacing strdup()
> > with an xstrdup() which in analogy to xmalloc() will quit with a fatal
> > error if the allocation fails.
> > 
> > xstrdup() is defined in srcpos.c, because that's available to both dtc
> > itself and the conversion program which also uses it.  While we're at
> > it, we add standard double-include protection to srcpos.h which was
> > missing it.
> > 
> > Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
> 
> 
> This was applied with a minor change, placing the new function
> in the file util.h and util.c instead.  New patch posted.

Yeah, reasonable change, I probably should have done that.  Actually I
probably should have created a util.c when I first made convert-dtsv0,
to contain the die() and xmalloc() functions.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson



More information about the devicetree-discuss mailing list