lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8df438f1-354a-7e2c-53c5-872f32c56a7@linux.intel.com>
Date:   Fri, 11 Aug 2023 12:11:39 +0300 (EEST)
From:   Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To:     "Jiri Slaby (SUSE)" <jirislaby@...nel.org>
cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-serial <linux-serial@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Dan Carpenter <dan.carpenter@...aro.org>,
        linux-staging@...ts.linux.dev
Subject: Re: [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify
 gdm_tty_write()

On Thu, 10 Aug 2023, Jiri Slaby (SUSE) wrote:

> len and remain can never be negative in gdm_tty_write(). So remove such
> a check and move the check of remaining bytes to the loop condition.
> This way, the preceding 'if' is now superfluous too. Fix all that and
> make the code cleaner.
> 
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@...nel.org>
> Reported-by: Dan Carpenter <dan.carpenter@...aro.org>

I guess Suggested-by would be more appropriate since there's no problem 
being fixed here.

> Cc: linux-staging@...ts.linux.dev

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>

-- 
 i.



> ---
>  drivers/staging/gdm724x/gdm_tty.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
> index cbaaa8fa7474..67d9bf41e836 100644
> --- a/drivers/staging/gdm724x/gdm_tty.c
> +++ b/drivers/staging/gdm724x/gdm_tty.c
> @@ -158,10 +158,7 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)
>  	if (!gdm_tty_ready(gdm))
>  		return -ENODEV;
>  
> -	if (!len)
> -		return 0;
> -
> -	while (1) {
> +	while (remain) {
>  		size_t sending_len = min(MUX_TX_MAX_SIZE, remain);
>  		gdm->tty_dev->send_func(gdm->tty_dev->priv_dev,
>  					(void *)(buf + sent_len),
> @@ -171,8 +168,6 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)
>  					gdm);
>  		sent_len += sending_len;
>  		remain -= sending_len;
> -		if (remain <= 0)
> -			break;
>  	}
>  
>  	return len;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ