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] [day] [month] [year] [list]
Message-ID: <2025022632-syrup-regretful-79df@gregkh>
Date: Wed, 26 Feb 2025 16:49:45 -0800
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Valentin Vidic <vvidic@...entin-vidic.from.hr>
Cc: Jiri Slaby <jirislaby@...nel.org>, linux-kernel@...r.kernel.org,
	linux-serial@...r.kernel.org
Subject: Re: [PATCH] tty: pty: remove redundant local variable

On Wed, Feb 26, 2025 at 09:47:07PM +0100, Valentin Vidic wrote:
> The value of to is only used once, so no need to store it in a
> variable.
> 
> Signed-off-by: Valentin Vidic <vvidic@...entin-vidic.from.hr>
> ---
>  drivers/tty/pty.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
> index df08f13052ff..c6eb711500b6 100644
> --- a/drivers/tty/pty.c
> +++ b/drivers/tty/pty.c
> @@ -110,12 +110,10 @@ static void pty_unthrottle(struct tty_struct *tty)
>  
>  static ssize_t pty_write(struct tty_struct *tty, const u8 *buf, size_t c)
>  {
> -	struct tty_struct *to = tty->link;
> -
>  	if (tty->flow.stopped || !c)
>  		return 0;
>  
> -	return tty_insert_flip_string_and_push_buffer(to->port, buf, c);
> +	return tty_insert_flip_string_and_push_buffer(tty->link->port, buf, c);

does this actually change the resulting code any?

"to" actually means something here, the tty is the "from" and the link
is the "to" where the data is going, so having it be "to" makes the code
easier to understand by humans, which is the first goal of code.
Maintaining it for long periods of time is key.

Otherwise your change "tty->link->port" doesn't make it all that obvious
that the this is being written not to the tty device itself, but to
somewhere else, right?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ