From: David Gibson Subject: Re: [PATCH] Implement and use an xstrdup() function Date: Sat, 4 Oct 2008 12:41:42 +1000 Message-ID: <20081004024142.GC30184@yookeroo.seuss> References: <1223054108-22342-1-git-send-email-jdl@jdl.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1223054108-22342-1-git-send-email-jdl-CYoMK+44s/E@public.gmane.org> 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:15:08PM -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. > > I felt the introduciton of util.[ch] was a better choice > for utility oriented code than directly using srcpos.c > for the new string function. Fair enough. Now that we have a util.c, we should move die() and xmalloc() in there as well which are currently duplicated between dtc and convert-dtsv0. > This patch is a re-factoring of Dave Gibson's similar patch. > > Signed-off-by: Jon Loeliger Acked-by: David Gibson -- 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