summaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-09-02 12:04:58 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-09-13 12:07:55 +0200
commit31b8b7254f2bfd8dd03522dee50a92cbf44a448d (patch)
tree3bb12fa7a330ccfbf7897945766fa852a423c527 /commands
parent579a72e317362ca2e1d4d9692c1b082c535203b5 (diff)
downloadbarebox-31b8b7254f2bfd8dd03522dee50a92cbf44a448d.tar.gz
commands: mm: don't ignore pread() errors for larger access sizes
Error check was before pread was called and because ret was initialized, compiler didn't warn about it. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220902100458.2597350-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/mm.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/commands/mm.c b/commands/mm.c
index 9ce8839644..8fe87a80a1 100644
--- a/commands/mm.c
+++ b/commands/mm.c
@@ -16,7 +16,7 @@
static int do_mem_mm(int argc, char *argv[])
{
- int ret = 0;
+ int ret;
int fd;
char *filename = "/dev/mem";
int mode = O_RWSIZE_4;
@@ -65,9 +65,9 @@ static int do_mem_mm(int argc, char *argv[])
goto out_write;
break;
case O_RWSIZE_4:
+ ret = pread(fd, &val32, 4, adr);
if (ret < 0)
goto out_read;
- ret = pread(fd, &val32, 4, adr);
val32 &= ~mask;
val32 |= (value & mask);
ret = pwrite(fd, &val32, 4, adr);
@@ -75,9 +75,9 @@ static int do_mem_mm(int argc, char *argv[])
goto out_write;
break;
case O_RWSIZE_8:
+ ret = pread(fd, &val64, 8, adr);
if (ret < 0)
goto out_read;
- ret = pread(fd, &val64, 8, adr);
val64 &= ~mask;
val64 |= (value & mask);
ret = pwrite(fd, &val64, 8, adr);