2023-09-19 09:06:57

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 00/15] random tty fixes

This is a collection of random fixes for tty I did while crawling
through the code. Mostly done for readability and understandability. No
behavior change intended (except for Documentation fixes).

Jiri Slaby (SUSE) (15):
tty: n_tty: use 'retval' instead of 'c'
tty: n_tty: rename and retype 'retval' in n_tty_ioctl()
tty: n_tty: use min3() in copy_from_read_buf()
tty: n_tty: invert the condition in copy_from_read_buf()
tty: n_tty: use do-while in n_tty_check_{,un}throttle()
tty: switch tty_{,un}throttle_safe() to return a bool
tty: invert return values of tty_{,un}throttle_safe()
tty: fix up and plug in tty_ioctl kernel-doc
tty: fix kernel-doc for functions in tty.h
tty: stop using ndash in kernel-doc
tty: tty_buffer: use bool for 'restart' in
tty_buffer_unlock_exclusive()
tty: convert THROTTLE constants into enum
tty: early return from send_break() on TTY_DRIVER_HARDWARE_BREAK
tty: don't check for signal_pending() in send_break()
tty: use 'if' in send_break() instead of 'goto'

Documentation/driver-api/tty/index.rst | 1 +
Documentation/driver-api/tty/tty_ioctl.rst | 10 +
drivers/tty/n_tty.c | 77 ++++---
drivers/tty/tty.h | 13 +-
drivers/tty/tty_buffer.c | 5 +-
drivers/tty/tty_io.c | 36 ++--
drivers/tty/tty_ioctl.c | 234 ++++++++++-----------
drivers/tty/tty_port.c | 6 +-
drivers/tty/vt/consolemap.c | 2 +-
drivers/tty/vt/vc_screen.c | 4 +-
drivers/tty/vt/vt.c | 4 +-
include/linux/tty.h | 25 +--
12 files changed, 209 insertions(+), 208 deletions(-)
create mode 100644 Documentation/driver-api/tty/tty_ioctl.rst

--
2.42.0


2023-09-19 09:07:01

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 01/15] tty: n_tty: use 'retval' instead of 'c'

In n_tty_read(), there is a separate int variable 'c' and is used only
to hold an int value returned from job_control(). There is also a
'retval' variable typed ssize_t. So drop this single occurrence of 'c'
and reuse 'retval' which is used on all other places to hold the value
returned from n_tty_read().

Note that 'retval' needs not be initialized now. Drop that.

Signed-off-by: Jiri Slaby (SUSE) <[email protected]>
---
drivers/tty/n_tty.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 6c9a408d67cd..71aa898b077a 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -2154,9 +2154,8 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf,
struct n_tty_data *ldata = tty->disc_data;
u8 *kb = kbuf;
DEFINE_WAIT_FUNC(wait, woken_wake_function);
- int c;
int minimum, time;
- ssize_t retval = 0;
+ ssize_t retval;
long timeout;
bool packet;
size_t old_tail;
@@ -2192,9 +2191,9 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf,
return kb - kbuf;
}

- c = job_control(tty, file);
- if (c < 0)
- return c;
+ retval = job_control(tty, file);
+ if (retval < 0)
+ return retval;

/*
* Internal serialization of reads.
--
2.42.0

2023-09-19 10:28:00

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 00/15] random tty fixes

On Tue, Sep 19, 2023 at 01:17:49PM +0300, Ilpo J?rvinen wrote:
> On Tue, 19 Sep 2023, Jiri Slaby (SUSE) wrote:
>
> > This is a collection of random fixes for tty I did while crawling
> > through the code. Mostly done for readability and understandability. No
> > behavior change intended (except for Documentation fixes).
> >
> > Jiri Slaby (SUSE) (15):
> > tty: n_tty: use 'retval' instead of 'c'
> > tty: n_tty: rename and retype 'retval' in n_tty_ioctl()
> > tty: n_tty: use min3() in copy_from_read_buf()
> > tty: n_tty: invert the condition in copy_from_read_buf()
> > tty: n_tty: use do-while in n_tty_check_{,un}throttle()
> > tty: switch tty_{,un}throttle_safe() to return a bool
> > tty: invert return values of tty_{,un}throttle_safe()
> > tty: fix up and plug in tty_ioctl kernel-doc
> > tty: fix kernel-doc for functions in tty.h
> > tty: stop using ndash in kernel-doc
> > tty: tty_buffer: use bool for 'restart' in
> > tty_buffer_unlock_exclusive()
> > tty: convert THROTTLE constants into enum
> > tty: early return from send_break() on TTY_DRIVER_HARDWARE_BREAK
> > tty: don't check for signal_pending() in send_break()
> > tty: use 'if' in send_break() instead of 'goto'
> >
> > Documentation/driver-api/tty/index.rst | 1 +
> > Documentation/driver-api/tty/tty_ioctl.rst | 10 +
> > drivers/tty/n_tty.c | 77 ++++---
> > drivers/tty/tty.h | 13 +-
> > drivers/tty/tty_buffer.c | 5 +-
> > drivers/tty/tty_io.c | 36 ++--
> > drivers/tty/tty_ioctl.c | 234 ++++++++++-----------
> > drivers/tty/tty_port.c | 6 +-
> > drivers/tty/vt/consolemap.c | 2 +-
> > drivers/tty/vt/vc_screen.c | 4 +-
> > drivers/tty/vt/vt.c | 4 +-
> > include/linux/tty.h | 25 +--
> > 12 files changed, 209 insertions(+), 208 deletions(-)
> > create mode 100644 Documentation/driver-api/tty/tty_ioctl.rst
>
> For this whole series except the patches I commented on:
>
> Reviewed-by: Ilpo J?rvinen <[email protected]>
>
> ...If you make the amendments I requested, please add the tag also to the
> patches I commented on.

That's horrible, b4 will now just add this reviewed-by to all of them
when I run it :(

greg k-h

2023-09-19 11:06:40

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH 00/15] random tty fixes

On Tue, 19 Sep 2023, Greg Kroah-Hartman wrote:

> On Tue, Sep 19, 2023 at 01:17:49PM +0300, Ilpo J?rvinen wrote:
> > On Tue, 19 Sep 2023, Jiri Slaby (SUSE) wrote:
> >
> > > This is a collection of random fixes for tty I did while crawling
> > > through the code. Mostly done for readability and understandability. No
> > > behavior change intended (except for Documentation fixes).
> > >
> > > Jiri Slaby (SUSE) (15):
> > > tty: n_tty: use 'retval' instead of 'c'
> > > tty: n_tty: rename and retype 'retval' in n_tty_ioctl()
> > > tty: n_tty: use min3() in copy_from_read_buf()
> > > tty: n_tty: invert the condition in copy_from_read_buf()
> > > tty: n_tty: use do-while in n_tty_check_{,un}throttle()
> > > tty: switch tty_{,un}throttle_safe() to return a bool
> > > tty: invert return values of tty_{,un}throttle_safe()
> > > tty: fix up and plug in tty_ioctl kernel-doc
> > > tty: fix kernel-doc for functions in tty.h
> > > tty: stop using ndash in kernel-doc
> > > tty: tty_buffer: use bool for 'restart' in
> > > tty_buffer_unlock_exclusive()
> > > tty: convert THROTTLE constants into enum
> > > tty: early return from send_break() on TTY_DRIVER_HARDWARE_BREAK
> > > tty: don't check for signal_pending() in send_break()
> > > tty: use 'if' in send_break() instead of 'goto'
> > >
> > > Documentation/driver-api/tty/index.rst | 1 +
> > > Documentation/driver-api/tty/tty_ioctl.rst | 10 +
> > > drivers/tty/n_tty.c | 77 ++++---
> > > drivers/tty/tty.h | 13 +-
> > > drivers/tty/tty_buffer.c | 5 +-
> > > drivers/tty/tty_io.c | 36 ++--
> > > drivers/tty/tty_ioctl.c | 234 ++++++++++-----------
> > > drivers/tty/tty_port.c | 6 +-
> > > drivers/tty/vt/consolemap.c | 2 +-
> > > drivers/tty/vt/vc_screen.c | 4 +-
> > > drivers/tty/vt/vt.c | 4 +-
> > > include/linux/tty.h | 25 +--
> > > 12 files changed, 209 insertions(+), 208 deletions(-)
> > > create mode 100644 Documentation/driver-api/tty/tty_ioctl.rst
> >
> > For this whole series except the patches I commented on:
> >
> > Reviewed-by: Ilpo J?rvinen <[email protected]>
> >
> > ...If you make the amendments I requested, please add the tag also to the
> > patches I commented on.
>
> That's horrible, b4 will now just add this reviewed-by to all of them
> when I run it :(

Okay, I'll try to avoid it in the future.

--
i.

2023-09-19 15:15:10

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH 00/15] random tty fixes

On Tue, 19 Sep 2023, Jiri Slaby (SUSE) wrote:

> This is a collection of random fixes for tty I did while crawling
> through the code. Mostly done for readability and understandability. No
> behavior change intended (except for Documentation fixes).
>
> Jiri Slaby (SUSE) (15):
> tty: n_tty: use 'retval' instead of 'c'
> tty: n_tty: rename and retype 'retval' in n_tty_ioctl()
> tty: n_tty: use min3() in copy_from_read_buf()
> tty: n_tty: invert the condition in copy_from_read_buf()
> tty: n_tty: use do-while in n_tty_check_{,un}throttle()
> tty: switch tty_{,un}throttle_safe() to return a bool
> tty: invert return values of tty_{,un}throttle_safe()
> tty: fix up and plug in tty_ioctl kernel-doc
> tty: fix kernel-doc for functions in tty.h
> tty: stop using ndash in kernel-doc
> tty: tty_buffer: use bool for 'restart' in
> tty_buffer_unlock_exclusive()
> tty: convert THROTTLE constants into enum
> tty: early return from send_break() on TTY_DRIVER_HARDWARE_BREAK
> tty: don't check for signal_pending() in send_break()
> tty: use 'if' in send_break() instead of 'goto'
>
> Documentation/driver-api/tty/index.rst | 1 +
> Documentation/driver-api/tty/tty_ioctl.rst | 10 +
> drivers/tty/n_tty.c | 77 ++++---
> drivers/tty/tty.h | 13 +-
> drivers/tty/tty_buffer.c | 5 +-
> drivers/tty/tty_io.c | 36 ++--
> drivers/tty/tty_ioctl.c | 234 ++++++++++-----------
> drivers/tty/tty_port.c | 6 +-
> drivers/tty/vt/consolemap.c | 2 +-
> drivers/tty/vt/vc_screen.c | 4 +-
> drivers/tty/vt/vt.c | 4 +-
> include/linux/tty.h | 25 +--
> 12 files changed, 209 insertions(+), 208 deletions(-)
> create mode 100644 Documentation/driver-api/tty/tty_ioctl.rst

For this whole series except the patches I commented on:

Reviewed-by: Ilpo J?rvinen <[email protected]>

...If you make the amendments I requested, please add the tag also to the
patches I commented on.

--
i.