From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson Subject: Re: [1/5] dtc: Implement and use an xstrdup() function Date: Sat, 4 Oct 2008 12:49:58 +1000 Message-ID: <20081004024958.GE30184@yookeroo.seuss> References: <20081002140427.GD11662@yookeroo.seuss> <20081002140512.GE11662@yookeroo.seuss> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-mnsaURCQ41sdnm+yROfE0A@public.gmane.org Errors-To: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-mnsaURCQ41sdnm+yROfE0A@public.gmane.org To: Jon Loeliger Cc: devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org List-Id: devicetree@vger.kernel.org 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 > > > 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