linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: speakup: selection: replace _manual_ swap with swap macro
@ 2017-11-10 22:13 Gustavo A. R. Silva
  2017-11-11  2:03 ` Samuel Thibault
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-10 22:13 UTC (permalink / raw)
  To: William Hubbs, Chris Brannon, Kirk Reiser, Samuel Thibault,
	Greg Kroah-Hartman
  Cc: speakup, devel, linux-kernel, Gustavo A. R. Silva

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.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/staging/speakup/selection.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/speakup/selection.c b/drivers/staging/speakup/selection.c
index 66061b5..0ed1fef 100644
--- a/drivers/staging/speakup/selection.c
+++ b/drivers/staging/speakup/selection.c
@@ -64,13 +64,8 @@ int speakup_set_selection(struct tty_struct *tty)
 	ps = spk_ys * vc->vc_size_row + (spk_xs << 1);
 	pe = spk_ye * vc->vc_size_row + (spk_xe << 1);
 
-	if (ps > pe) {
-		/* make sel_start <= sel_end */
-		int tmp = ps;
-
-		ps = pe;
-		pe = tmp;
-	}
+	if (ps > pe)	/* make sel_start <= sel_end */
+		swap(ps, pe);
 
 	if (spk_sel_cons != vc_cons[fg_console].d) {
 		speakup_clear_selection();
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: speakup: selection: replace _manual_ swap with swap macro
  2017-11-10 22:13 [PATCH] staging: speakup: selection: replace _manual_ swap with swap macro Gustavo A. R. Silva
@ 2017-11-11  2:03 ` Samuel Thibault
  0 siblings, 0 replies; 2+ messages in thread
From: Samuel Thibault @ 2017-11-11  2:03 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, Greg Kroah-Hartman,
	speakup, devel, linux-kernel

Gustavo A. R. Silva, on ven. 10 nov. 2017 16:13:03 -0600, wrote:
> 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.
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>

Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  drivers/staging/speakup/selection.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/speakup/selection.c b/drivers/staging/speakup/selection.c
> index 66061b5..0ed1fef 100644
> --- a/drivers/staging/speakup/selection.c
> +++ b/drivers/staging/speakup/selection.c
> @@ -64,13 +64,8 @@ int speakup_set_selection(struct tty_struct *tty)
>  	ps = spk_ys * vc->vc_size_row + (spk_xs << 1);
>  	pe = spk_ye * vc->vc_size_row + (spk_xe << 1);
>  
> -	if (ps > pe) {
> -		/* make sel_start <= sel_end */
> -		int tmp = ps;
> -
> -		ps = pe;
> -		pe = tmp;
> -	}
> +	if (ps > pe)	/* make sel_start <= sel_end */
> +		swap(ps, pe);
>  
>  	if (spk_sel_cons != vc_cons[fg_console].d) {
>  		speakup_clear_selection();
> -- 
> 2.7.4
> 

-- 
Samuel
<b> il faut combien de chevaux pour tirer une doloréan à 88 morph ?
***b vient de remarque que 88 mph c'est 142 km/h
<y> aaaaah
<y> c'est pour ça qu'ils limitent à 130 km/h sur les autoroutes
<y> c'est pour éviter que les gens voyagent dans le temps
<b> probablement

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-11  2:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-10 22:13 [PATCH] staging: speakup: selection: replace _manual_ swap with swap macro Gustavo A. R. Silva
2017-11-11  2:03 ` Samuel Thibault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).