From e54dfcc0666658425dfc2f813509629a9f54073a Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 2 Mar 2025 11:42:57 -0600 Subject: [PATCH] Fix the read() and write() path: zero for small reads and support big endian. --- toys/other/devmem.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/toys/other/devmem.c b/toys/other/devmem.c index 90c25060..9c579d0a 100644 --- a/toys/other/devmem.c +++ b/toys/other/devmem.c @@ -43,9 +43,10 @@ unsigned long xatolu(char *str, int bytes) void devmem_main(void) { int ii, writing = toys.optc > 2, bytes = 4, fd; - unsigned long data QUIET, map_len QUIET, + unsigned long data = 0, map_len QUIET, addr = xatolu(*toys.optargs, sizeof(long)); void *map QUIET, *p QUIET; + char *pdata; // WIDTH? if (toys.optc>1) { @@ -55,6 +56,7 @@ void devmem_main(void) error_exit("bad width: %s", toys.optargs[1]); bytes = 1<