From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ladislav Michl Date: Mon, 29 Nov 2004 16:19:14 +0100 Subject: [U-Boot-Users] Re: [PATCH] !CFG_MEMTEST_SCRATCH - do not dereference NULL In-Reply-To: References: <065ACD8E84315E4394C835E398C8D5EBB1B8B0@COSSMGMBX02.email.corp.tld> Message-ID: <20041129151914.GA14382@simek> 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, Nov 29, 2004 at 03:33:16PM +0100, Anders Larsen wrote: > "VanBaren, Gerald (AGRE)" : > >The proper fix is, for your board, change > >the assignment "vu_long *dummy = 0x00000000;" to point to writable RAM > >on your board. > > This is the purpose of CFG_MEMTEST_SCRATCH. > > Please, please read the README, which says: > "- CFG_MEMTEST_SCRATCH: > Scratch address used by the alternate memory test > You only need to set this if address zero isn't writeable" Ah, sorry. I looked only at code and it seemed wrong to me. See below. > The last statement implies that you DO need to set > CFG_MEMTEST_SCRATCH if address zero ISN'T writeable. > > No need to change any code at all. Thanks, now I see the code works how author intended. But I do not agree with the way how it is written. NULL pointer means invalid pointer, while "vu_long *dummy = 0x00000000;" means valid pointer to address zero (and yes I know they both will lead to the same machine code ;-)) Consider patch bellow. Now a little question. Would you mind a patch making scratch area optional? Regards, ladis Index: common/cmd_mem.c =================================================================== RCS file: /cvsroot/u-boot/u-boot/common/cmd_mem.c,v retrieving revision 1.19 diff -u -r1.19 cmd_mem.c --- common/cmd_mem.c 10 Oct 2004 23:27:33 -0000 1.19 +++ common/cmd_mem.c 29 Nov 2004 15:14:40 -0000 @@ -646,8 +646,8 @@ vu_long num_words; #if defined(CFG_MEMTEST_SCRATCH) vu_long *dummy = (vu_long*)CFG_MEMTEST_SCRATCH; -#else - vu_long *dummy = NULL; +#else /* Undefined if address zero is writeable */ + vu_long *dummy = (vu_long*)0x00000000; #endif int j; int iterations = 1;