From: Ladislav Michl <ladis@linux-mips.org>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Re: [PATCH] !CFG_MEMTEST_SCRATCH - do not dereference NULL
Date: Mon, 29 Nov 2004 16:19:14 +0100 [thread overview]
Message-ID: <20041129151914.GA14382@simek> (raw)
In-Reply-To: <fc.004c4e48002b832d3b9aca00a5363478.2b835f@rea.de>
On Mon, Nov 29, 2004 at 03:33:16PM +0100, Anders Larsen wrote:
> "VanBaren, Gerald (AGRE)" <Gerald.VanBaren@smiths-aerospace.com>:
> >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;
next prev parent reply other threads:[~2004-11-29 15:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-29 14:15 [U-Boot-Users] Re: [PATCH] !CFG_MEMTEST_SCRATCH - do not dereference NULL ptr VanBaren, Gerald
2004-11-29 14:33 ` [U-Boot-Users] [PATCH] !CFG_MEMTEST_SCRATCH - do not dereference NULL Anders Larsen
2004-11-29 15:19 ` Ladislav Michl [this message]
2004-11-29 15:35 ` [U-Boot-Users] Re: [PATCH] !CFG_MEMTEST_SCRATCH - do not dereference NULL ptr Ladislav Michl
2005-05-30 12:44 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041129151914.GA14382@simek \
--to=ladis@linux-mips.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.