From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Tue, 27 Sep 2011 23:04:03 +0200 Subject: [U-Boot] [PATCH 4/5 V2] NAND: Make page, erase, oob size available via cmd_nand In-Reply-To: <4E8237E4.9020305@freescale.com> References: <1315800250-19761-5-git-send-email-marek.vasut@gmail.com> <201109272207.05434.marek.vasut@gmail.com> <4E8237E4.9020305@freescale.com> Message-ID: <201109272304.03365.marek.vasut@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tuesday, September 27, 2011 10:53:56 PM Scott Wood wrote: > On 09/27/2011 03:07 PM, Marek Vasut wrote: > > On Tuesday, September 27, 2011 09:51:09 PM Scott Wood wrote: > >> On 09/27/2011 02:38 PM, Marek Vasut wrote: > >>> On Tuesday, September 27, 2011 09:01:53 PM Scott Wood wrote: > >>>> On Thu, Sep 22, 2011 at 03:57:26AM +0200, Marek Vasut wrote: > >>>>> + /* Set geometry info */ > >>>>> + memset(buf, 0, bufsz); > >>>>> + sprintf(buf, "%x", nand->writesize); > >>>>> + setenv("nand_writesize", buf); > >>>>> + > >>>>> + memset(buf, 0, bufsz); > >>>>> + sprintf(buf, "%x", nand->oobsize); > >>>>> + setenv("nand_oobsize", buf); > >>>>> + > >>>>> + memset(buf, 0, bufsz); > >>>>> + sprintf(buf, "%x", nand->erasesize); > >>>>> + setenv("nand_erasesize", buf); > >>>> > >>>> Why the memsets? > >>> > >>> To clear the memory from previous usage ? > >> > >> What part of the previous usage will both survive the sprintf() and be > >> looked at by setenv()? > > > > The part of data that are copied in _do_set_env() ? > > I don't see _do_set_env anywhere -- what tree are you looking at? > > In any case, sprintf() produces a zero-terminated string. setenv() > consumes a zero-terminated string. Correct > setenv() doesn't even know that the > buffer containing the string happens to be 32 bytes, much less have any > business poking around in that area. True ... but the stuff you call setenv() on is copied to environment. That's about it, it doesn't get lost anywhere.