aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-05-11 16:12:25 -0700
committerRob Landley <rob@landley.net>2020-05-13 17:29:12 -0500
commit9de5f300363c788a5cd7d9eaf12f583d7f766502 (patch)
treea0fc2a29d49f83c7920ea45f94d35a3eb401f085 /toys/other
parentf5ca2bcf2b5c46aa532a767bed08e2425a1a6fd4 (diff)
downloadtoybox-9de5f300363c788a5cd7d9eaf12f583d7f766502.tar.gz
devmem: avoid sign extension.
Bug: http://b/156292059 Signed-off-by: Wei Wang <wvw@google.com>
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/devmem.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/toys/other/devmem.c b/toys/other/devmem.c
index a6f9f606..6e270df0 100644
--- a/toys/other/devmem.c
+++ b/toys/other/devmem.c
@@ -47,15 +47,15 @@ void devmem_main(void)
// Not using peek()/poke() because registers care about size of read/write
if (writing) {
- if (bytes == 1) *(char *)p = data;
- else if (bytes == 2) *(short *)p = data;
- else if (bytes == 4) *(int *)p = data;
- else if (bytes == 8) *(long long *)p = data;
+ if (bytes == 1) *(unsigned char *)p = data;
+ else if (bytes == 2) *(unsigned short *)p = data;
+ else if (bytes == 4) *(unsigned int *)p = data;
+ else if (bytes == 8) *(unsigned long long *)p = data;
} else {
- if (bytes == 1) data = *(char *)p;
- else if (bytes == 2) data = *(short *)p;
- else if (bytes == 4) data = *(int *)p;
- else if (bytes == 8) data = *(long long *)p;
+ if (bytes == 1) data = *(unsigned char *)p;
+ else if (bytes == 2) data = *(unsigned short *)p;
+ else if (bytes == 4) data = *(unsigned int *)p;
+ else if (bytes == 8) data = *(unsigned long long *)p;
printf("%#0*llx\n", bytes*2, data);
}