Skip to contentSkip to conversation

tty: vt: replace _manual_ swap with swap macro in set_selection

PATCH New Gustavo A. R. Silva 1 participant 1 message Nov 10, 2017 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: vt: replace _manual_ swap with swap macro in set_selection

Make use of the swap macro instead of _manually_ swapping values and remove unnecessary variable tmp.

This makes the code easier to read and maintain.

This code was detected with the help of Coccinelle.

---
 drivers/tty/vt/selection.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/tty/vt/selection.c +1 -5
index af4da95..7851383 100644
@@ -186,11 +186,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
 	}
 
 	if (ps > pe)	/* make sel_start <= sel_end */
-	{
-		int tmp = ps;
-		ps = pe;
-		pe = tmp;
-	}
+		swap(ps, pe);
 
 	if (sel_cons != vc_cons[fg_console].d) {
 		clear_selection();
Signature · 1 line
2.7.4