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@xxxxxxxxxxxxxx> --- commands/mm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/mm.c b/commands/mm.c index 9ce883964485..8fe87a80a18e 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); -- 2.30.2