Re: [PATCH] commands: mm: don't ignore pread() errors for larger access sizes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux