Dear all,

Attached is a patch for cmd_itest.c
This fixes data access for .b and .w
If there are issues applying the patch feel free to mail me and I will
resent from home.
And of course I am open to comments.

There is one note: the evalexp function returns a long.
For .b and .w access I choose to return an unsigned char resp unsigned
short casted to long.
It is my impression that would be desirable, but if not, feel free to change
(and it might also be desirable to change the long to unsigned long,
but as that ripples up to the caller, I decided not to touch that
part.

Best regards, Frans.

>From 93143ca97f1cd10a7ddf04c15e2dc9e1b2f10317 Mon Sep 17 00:00:00 2001
From: Frans Meulenbroeks <fransmeulenbro...@gmail.com>
Date: Fri, 19 Feb 2010 14:50:53 +0100
Subject: [PATCH] cmd_itest.c: fix pointer dereferencing

fix pointer dereferencing
if the size is .b and .w an 8 or 16 bit access is done.

Signed-off-by: Frans Meulenbroeks <fransmeulenbro...@gmail.com>
---
 common/cmd_itest.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index 5b301bf..d0ef747 100644
--- a/common/cmd_itest.c
+++ b/common/cmd_itest.c
@@ -66,17 +66,23 @@ op_tbl_t op_table [] = {

 static long evalexp(char *s, int w)
 {
-       long l, *p;
+       long l = 0; /* default return value */
+       long *p;

+       
        /* 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);
+               }
        } else {
                l = simple_strtoul(s, NULL, 16);
        }
-
        return (l & ((1 << (w * 8)) - 1));
+
 }

 static char * evalstr(char *s)
-- 
1.5.4.3
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to