From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] commands: mm: don't ignore pread() errors for larger access sizes
Date: Fri, 2 Sep 2022 12:04:58 +0200 [thread overview]
Message-ID: <20220902100458.2597350-1-a.fatoum@pengutronix.de> (raw)
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>
---
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
next reply other threads:[~2022-09-02 10:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-02 10:04 Ahmad Fatoum [this message]
2022-09-12 10:14 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220902100458.2597350-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox