mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] commands: mm: don't ignore pread() errors for larger access sizes
Date: Mon, 12 Sep 2022 12:14:46 +0200	[thread overview]
Message-ID: <20220912101446.GD6477@pengutronix.de> (raw)
In-Reply-To: <20220902100458.2597350-1-a.fatoum@pengutronix.de>

On Fri, Sep 02, 2022 at 12:04:58PM +0200, Ahmad Fatoum wrote:
> 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(-)

Applied, thanks

Sascha

> 
> 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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2022-09-12 10:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02 10:04 Ahmad Fatoum
2022-09-12 10:14 ` Sascha Hauer [this message]

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=20220912101446.GD6477@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=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