[7/8] n_tty: Reindent if condition

Message ID 20230309082035.14880-8-ilpo.jarvinen@linux.intel.com
State New
Headers
Series tty: Cleanups |

Commit Message

Ilpo Järvinen March 9, 2023, 8:20 a.m. UTC
  Align if condition to make it easier to read.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/n_tty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jiri Slaby March 9, 2023, 1:45 p.m. UTC | #1
On 09. 03. 23, 9:20, Ilpo Järvinen wrote:
> Align if condition to make it easier to read.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>   drivers/tty/n_tty.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
> index 0481e57077f1..1c9e5d2ea7de 100644
> --- a/drivers/tty/n_tty.c
> +++ b/drivers/tty/n_tty.c
> @@ -1176,7 +1176,7 @@ static void n_tty_receive_overrun(struct tty_struct *tty)
>   
>   	ldata->num_overrun++;
>   	if (time_after(jiffies, ldata->overrun_time + HZ) ||
> -			time_after(ldata->overrun_time, jiffies)) {
> +	    time_after(ldata->overrun_time, jiffies)) {

Staring at this, what the second time_after() does in the first place?

>   		tty_warn(tty, "%d input overrun(s)\n", ldata->num_overrun);
>   		ldata->overrun_time = jiffies;
>   		ldata->num_overrun = 0;
  
Ilpo Järvinen March 9, 2023, 1:59 p.m. UTC | #2
On Thu, 9 Mar 2023, Jiri Slaby wrote:

> On 09. 03. 23, 9:20, Ilpo Järvinen wrote:
> > Align if condition to make it easier to read.
> > 
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> > ---
> >   drivers/tty/n_tty.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
> > index 0481e57077f1..1c9e5d2ea7de 100644
> > --- a/drivers/tty/n_tty.c
> > +++ b/drivers/tty/n_tty.c
> > @@ -1176,7 +1176,7 @@ static void n_tty_receive_overrun(struct tty_struct
> > *tty)
> >     	ldata->num_overrun++;
> >   	if (time_after(jiffies, ldata->overrun_time + HZ) ||
> > -			time_after(ldata->overrun_time, jiffies)) {
> > +	    time_after(ldata->overrun_time, jiffies)) {
> 
> Staring at this, what the second time_after() does in the first place?
> 
> >   		tty_warn(tty, "%d input overrun(s)\n", ldata->num_overrun);
> >   		ldata->overrun_time = jiffies;
> >   		ldata->num_overrun = 0;

That's a very good question ... I first thought it was checking whether 
the jiffies is between two times but obviously that was wrong intuition 
now when taking a closer look.

But then, looking more into it, this whole thing looks an opencoded 
*_ratelimited print. So perhaps overrun_time could be removed 
completely... ? I can see it kinda changes priority of which messages 
would get filtered out but I don't know if that's a problem or not.
  

Patch

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 0481e57077f1..1c9e5d2ea7de 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1176,7 +1176,7 @@  static void n_tty_receive_overrun(struct tty_struct *tty)
 
 	ldata->num_overrun++;
 	if (time_after(jiffies, ldata->overrun_time + HZ) ||
-			time_after(ldata->overrun_time, jiffies)) {
+	    time_after(ldata->overrun_time, jiffies)) {
 		tty_warn(tty, "%d input overrun(s)\n", ldata->num_overrun);
 		ldata->overrun_time = jiffies;
 		ldata->num_overrun = 0;