From: Detlev Zundel <dzu@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] cmd_itest.c: fix pointer dereferencing
Date: Mon, 22 Feb 2010 12:59:27 +0100 [thread overview]
Message-ID: <m2aav14h28.fsf@ohwell.denx.de> (raw)
In-Reply-To: <1266664980-19814-1-git-send-email-fransmeulenbroeks@gmail.com> (Frans Meulenbroeks's message of "Sat, 20 Feb 2010 12:23:00 +0100")
Hi Frans,
> fix pointer dereferencing
> if the size is .b and .w an 8 or 16 bit access is done.
>
> Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
> ---
> common/cmd_itest.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/common/cmd_itest.c b/common/cmd_itest.c
> index 5b301bf..6e1079c 100644
> --- a/common/cmd_itest.c
> +++ b/common/cmd_itest.c
> @@ -66,16 +66,19 @@ op_tbl_t op_table [] = {
>
> static long evalexp(char *s, int w)
> {
> - long l, *p;
> + long l = 0
> + long *p;
It takes chuzpe to send patches that do not even compile ;) Who ate the
';'?
>
> /* if the parameter starts with a * then assume is a pointer to the value we want */
> if (s[0] == '*') {
> p = (long *)simple_strtoul(&s[1], NULL, 16);
> - l = *p;
> + switch (w) {
> + case 1: return((long)(*(unsigned char *)p));
> + case 2: return((long)(*(unsigned short *)p));
> + case 4: return(*p);
The switch statement needs to be closed also.
> } else {
> l = simple_strtoul(s, NULL, 16);
> }
> -
> return (l & ((1 << (w * 8)) - 1));
> }
Once you fix the syntax errors -
Acked-by: Detlev Zundel <dzu@denx.de>
Cheers
Detlev
--
"Our enemies are innovative and resourceful, and so are we. They
never stop thinking about new ways to harm our country and our people,
and neither do we."
-- George W. Bush during a defense bill ceremony on 5. Aug 2004
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
next prev parent reply other threads:[~2010-02-22 11:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-20 11:23 [U-Boot] [PATCH 2/2] cmd_itest.c: fix pointer dereferencing Frans Meulenbroeks
2010-02-22 11:59 ` Detlev Zundel [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-02-22 21:49 Frans Meulenbroeks
2010-02-23 11:37 ` Detlev Zundel
2010-02-23 23:09 ` 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=m2aav14h28.fsf@ohwell.denx.de \
--to=dzu@denx.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox