From: Greg KH <gregkh@linuxfoundation.org>
To: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 09/10] tty: tty_buffer: initialize variables in initializers already
Date: Tue, 22 Aug 2023 14:56:27 +0200 [thread overview]
Message-ID: <2023082232-runaround-captive-aa7a@gregkh> (raw)
In-Reply-To: <20230816105530.3335-10-jirislaby@kernel.org>
On Wed, Aug 16, 2023 at 12:55:29PM +0200, Jiri Slaby (SUSE) wrote:
> It makes the code both more compact, and more understandable.
>
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> ---
> drivers/tty/tty_buffer.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
> index 414bb7f9155f..44c0adaec850 100644
> --- a/drivers/tty/tty_buffer.c
> +++ b/drivers/tty/tty_buffer.c
> @@ -262,17 +262,10 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size,
> bool flags)
> {
> struct tty_bufhead *buf = &port->buf;
> - struct tty_buffer *b, *n;
> - size_t left;
> - bool change;
> + struct tty_buffer *n, *b = buf->tail;
> + size_t left = (b->flags ? 1 : 2) * b->size - b->used;
That's understandable? Hah!
I'll take it, but ick, the original:
> + bool change = !b->flags && flags;
>
> - b = buf->tail;
> - if (!b->flags)
> - left = 2 * b->size - b->used;
> - else
> - left = b->size - b->used;
Is much more readable.
Well kind of, it's all a mess :)
thanks,
greg k-h
next prev parent reply other threads:[~2023-08-22 12:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-16 10:55 [PATCH 00/10] tty: tty_buffer: cleanup Jiri Slaby (SUSE)
2023-08-16 10:55 ` [PATCH 01/10] tty: tty_buffer: switch data type to u8 Jiri Slaby (SUSE)
2023-08-16 10:55 ` [PATCH 02/10] tty: tty_buffer: use struct_size() in tty_buffer_alloc() Jiri Slaby (SUSE)
2023-08-16 10:55 ` [PATCH 03/10] tty: tty_buffer: unify tty_insert_flip_string_{fixed_flag,flags}() Jiri Slaby (SUSE)
2023-08-16 10:55 ` [PATCH 04/10] tty: tty_buffer: warn if losing flags in __tty_insert_flip_string_flags() Jiri Slaby (SUSE)
2023-08-16 10:55 ` [PATCH 05/10] tty: tty_buffer: switch insert functions to size_t Jiri Slaby (SUSE)
2023-08-16 10:55 ` [PATCH 06/10] tty: tty_buffer: let tty_prepare_flip_string() return size_t Jiri Slaby (SUSE)
2023-08-16 10:55 ` [PATCH 07/10] tty: tty_buffer: use __tty_insert_flip_string_flags() in tty_insert_flip_char() Jiri Slaby (SUSE)
2023-08-16 10:55 ` [PATCH 08/10] tty: tty_buffer: better types in __tty_buffer_request_room() Jiri Slaby (SUSE)
2023-08-16 10:55 ` [PATCH 09/10] tty: tty_buffer: initialize variables in initializers already Jiri Slaby (SUSE)
2023-08-22 12:56 ` Greg KH [this message]
2023-08-16 10:55 ` [PATCH 10/10] tty: tty_buffer: invert conditions in __tty_buffer_request_room() Jiri Slaby (SUSE)
2023-08-22 12:58 ` [PATCH 00/10] tty: tty_buffer: cleanup Greg KH
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=2023082232-runaround-captive-aa7a@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.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