From: York Sun Date: Mon, 3 Jan 2011 13:26:31 -0800 Subject: [U-Boot] [PATCH v2 2/9] make the hwconfig buffer deeper In-Reply-To: <20110103211125.710E5CEF7A6@gemini.denx.de> References: <1292630381-23022-1-git-send-email-yorksun@freescale.com> <1292630381-23022-2-git-send-email-yorksun@freescale.com> <20101218222535.58FF31524E8@gemini.denx.de> <1294085287.24386.52.camel@oslab-l1> <20110103211125.710E5CEF7A6@gemini.denx.de> Message-ID: <1294089991.24386.58.camel@oslab-l1> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, 2011-01-03 at 22:11 +0100, Wolfgang Denk wrote: > Dear York Sun, > > In message <1294085287.24386.52.camel@oslab-l1> you wrote: > > > > > Please explain 1) why this is needed and 2) what it has to do with > > > running "at" (from?) flash? > > > > > > hwconfig is intended for simple h/w configurations. In which case do > > > you need more than 128 characters for such settings? And is this > > > really needed / reasonable? > > > > First of all, I don't need more than 128 characters for hwconfig. I > > think the buggy code makes the buffer less usable. > > Hm... I have no idea whish sort of "buggy code" you are referring to > here, but in this case we shoul start and fix that buggy code, right? Making a buffer in a function's stack and make use of it out of the scope, that's the buggy code I am referring. > > > If you look into the common/hwconfig.c, you will notice the _current_ > > code uses the stack as temporary memory to hold the variable. Even I > > don't agree with this way, I don't have a quick fix either. There may be > > What's wrong with putting it on the stack? This prevents a permanent > allocation, so the memory can easily be reused once that function > returns. How can the content be guaranteed? The stack can be trashed when the function returns. > > > two ways or more to fix it. One is to create wrapper functions to deal > > with pre-relocation and post-relocation functions. Another way is to > > allocate more space in gd. Which way do you think is better? > > You fail to explain why we should change anything when you "don't need > more than 128 characters for hwconfig" in the first place? I don't need more than 128 characters. However, the stack is trashed by other functions. I have to push the stack deeper to keep the content unchanged. I am not happy with it. York