Skip to contentSkip to conversation

cmd: replace the cast of the memory access to a fixed bit type in itest

PATCH In review Masahiro Yamada 4 participants 4 messages May 4, 2016 – May 30, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: replace the cast of the memory access to a fixed bit type in itest

From: Kunihiko Hayashi <[email protected]>

This patch fixes a bug that long word(.l) memory access in 'itest' command reads the 8bytes of the actual memory on 64-bit architecture. The cast to the memory pointer should use a fixed bit type.

---

 cmd/itest.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
cmd/itest.c +3 -3
index fb4d797..60626c7 100644
@@ -65,13 +65,13 @@ static long evalexp(char *s, int w)
 		}
 		switch (w) {
 		case 1:
-			l = (long)(*(unsigned char *)buf);
+			l = (long)(*(u8 *)buf);
 			break;
 		case 2:
-			l = (long)(*(unsigned short *)buf);
+			l = (long)(*(u16 *)buf);
 			break;
 		case 4:
-			l = (long)(*(unsigned long *)buf);
+			l = (long)(*(u32 *)buf);
 			break;
 		}
 		unmap_physmem(buf, w);
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 cmd: replace the cast of the memory access to a fixed bit type in itest

Quoted 25 lines · Masahiro Yamada

From: Kunihiko Hayashi <[email protected]>

This patch fixes a bug that long word(.l) memory access in 'itest' command reads the 8bytes of the actual memory on 64-bit architecture. The cast to the memory pointer should use a fixed bit type.

---

  cmd/itest.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
cmd/itest.c +1 -1
index fb4d797..60626c7 100644
@@ -65,13 +65,13 @@ static long evalexp(char *s, int w)
  		}
  		switch (w) {
  		case 1:
-			l = (long)(*(unsigned char *)buf);
+			l = (long)(*(u8 *)buf);
  			break;

cmd/itest.c static long evalexp(char *s, int w) · line 77

Quoted 10 lines
cmd/itest.c +2 -2
  		case 2:
-			l = (long)(*(unsigned short *)buf);
+			l = (long)(*(u16 *)buf);
  			break;
  		case 4:
-			l = (long)(*(unsigned long *)buf);
+			l = (long)(*(u32 *)buf);
  			break;
  		}
  		unmap_physmem(buf, w);

Thanks,
Stefan

#2 lore raw

PATCH 1/1 cmd: replace the cast of the memory access to a fixed bit type in itest

In reply to Masahiro Yamada
Quoted 6 lines · Masahiro Yamada

From: Kunihiko Hayashi <[email protected]>

This patch fixes a bug that long word(.l) memory access in 'itest' command reads the 8bytes of the actual memory on 64-bit architecture. The cast to the memory pointer should use a fixed bit type.

Quoted 6 lines

---

 cmd/itest.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 25 lines
cmd/itest.c +3 -4
index fb4d797..60626c7 100644
@@ -65,13 +65,13 @@ static long evalexp(char *s, int w)
                }
                switch (w) {
                case 1:
-                       l = (long)(*(unsigned char *)buf);
+                       l = (long)(*(u8 *)buf);
                        break;
                case 2:
-                       l = (long)(*(unsigned short *)buf);
+                       l = (long)(*(u16 *)buf);
                        break;
                case 4:
-                       l = (long)(*(unsigned long *)buf);
+                       l = (long)(*(u32 *)buf);
                        break;
                }
                unmap_physmem(buf, w);
--

1.9.1

#3 lore raw
In reply to Masahiro Yamada
Quoted 10 lines · Masahiro Yamada

From: Kunihiko Hayashi <[email protected]>

This patch fixes a bug that long word(.l) memory access in 'itest' command reads the 8bytes of the actual memory on 64-bit architecture. The cast to the memory pointer should use a fixed bit type.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/40816c0a/attachment.sig>