Skip to contentSkip to conversation

net: slcan, slip -- no need for goto when if () will do

PATCH Applied Pavel Machek 3 participants 3 messages Mar 9, 2020 – Mar 12, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: slcan, slip -- no need for goto when if () will do

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

drivers/net/can/slcan.c +2 -5
index 2f5c287eac95..686d853fc249 100644
@@ -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();
 }
 
drivers/net/slip/slip.c +2 -5
index babb01888b78..f81fb0b13a94 100644
@@ -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();
 }
 
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Pavel Machek

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

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

drivers/net/can/slcan.c static void slcan_write_wakeup(struct tty_struct *tty) · line 354

Quoted 10 lines
drivers/net/can/slcan.c +2 -5
  	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 ...

Quoted 20 lines
drivers/net/slip/slip.c +2 -5
index babb01888b78..f81fb0b13a94 100644
@@ -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();
  }