2020-03-09 22:35:24

by Pavel Machek

[permalink] [raw]
Subject: [PATCH] net: slcan, slip -- no need for goto when if () will do


No need to play with gotos to jump over single statement.

Signed-off-by: Pavel Machek <[email protected]>

diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index 2f5c287eac95..686d853fc249 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -348,11 +348,8 @@ static void slcan_write_wakeup(struct tty_struct *tty)

rcu_read_lock();
sl = rcu_dereference(tty->disc_data);
- if (!sl)
- goto out;
-
- schedule_work(&sl->tx_work);
-out:
+ if (sl)
+ schedule_work(&sl->tx_work);
rcu_read_unlock();
}

diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index babb01888b78..f81fb0b13a94 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -456,11 +456,8 @@ static void slip_write_wakeup(struct tty_struct *tty)

rcu_read_lock();
sl = rcu_dereference(tty->disc_data);
- if (!sl)
- goto out;
-
- schedule_work(&sl->tx_work);
-out:
+ if (sl)
+ schedule_work(&sl->tx_work);
rcu_read_unlock();
}


--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (1.12 kB)
signature.asc (201.00 B)
Download all attachments

2020-03-10 13:10:16

by Oliver Hartkopp

[permalink] [raw]
Subject: Re: [PATCH] net: slcan, slip -- no need for goto when if () will do



On 09/03/2020 23.33, Pavel Machek wrote:
>
> No need to play with gotos to jump over single statement.
>
> Signed-off-by: Pavel Machek <[email protected]>
>
> diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
> index 2f5c287eac95..686d853fc249 100644
> --- a/drivers/net/can/slcan.c
> +++ b/drivers/net/can/slcan.c
> @@ -348,11 +348,8 @@ static void slcan_write_wakeup(struct tty_struct *tty)
>
> rcu_read_lock();
> sl = rcu_dereference(tty->disc_data);
> - if (!sl)
> - goto out;
> -
> - schedule_work(&sl->tx_work);
> -out:
> + if (sl)
> + schedule_work(&sl->tx_work);
> rcu_read_unlock();
> }

Haha. Yes, that looks indeed much better ...

Acked-by: Oliver Hartkopp <[email protected]>

>
> diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
> index babb01888b78..f81fb0b13a94 100644
> --- a/drivers/net/slip/slip.c
> +++ b/drivers/net/slip/slip.c
> @@ -456,11 +456,8 @@ static void slip_write_wakeup(struct tty_struct *tty)
>
> rcu_read_lock();
> sl = rcu_dereference(tty->disc_data);
> - if (!sl)
> - goto out;
> -
> - schedule_work(&sl->tx_work);
> -out:
> + if (sl)
> + schedule_work(&sl->tx_work);
> rcu_read_unlock();
> }
>
>

2020-03-12 06:16:30

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] net: slcan, slip -- no need for goto when if () will do

From: Pavel Machek <[email protected]>
Date: Mon, 9 Mar 2020 23:33:23 +0100

> No need to play with gotos to jump over single statement.
>
> Signed-off-by: Pavel Machek <[email protected]>

Applied, thanks.