Linux Serial subsystem development
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Valentin Vidic <vvidic@valentin-vidic.from.hr>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH] tty: pty: remove redundant local variable
Date: Wed, 26 Feb 2025 16:49:45 -0800	[thread overview]
Message-ID: <2025022632-syrup-regretful-79df@gregkh> (raw)
In-Reply-To: <20250226204707.1941274-1-vvidic@valentin-vidic.from.hr>

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

  reply	other threads:[~2025-02-27  0:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26 20:47 [PATCH] tty: pty: remove redundant local variable Valentin Vidic
2025-02-27  0:49 ` Greg Kroah-Hartman [this message]
2025-02-27 18:40   ` Valentin Vidić

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=2025022632-syrup-regretful-79df@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=vvidic@valentin-vidic.from.hr \
    /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