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: <2023082232-runaround-captive-aa7a@gregkh>
Date:   Tue, 22 Aug 2023 14:56:27 +0200
From:   Greg KH <gregkh@...uxfoundation.org>
To:     "Jiri Slaby (SUSE)" <jirislaby@...nel.org>
Cc:     linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 09/10] tty: tty_buffer: initialize variables in
 initializers already

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@...nel.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ