linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1 linux-next] pnfs/flexfiles: use swap() in ff_layout_sort_mirrors()
@ 2015-06-12 16:58 Fabian Frederick
  2015-06-12 17:17 ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Fabian Frederick @ 2015-06-12 16:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Julia Lawall, Fabian Frederick, Trond Myklebust, Anna Schumaker,
	linux-nfs

Use kernel.h macro definition.

Thanks to Julia Lawall for Coccinelle scripting support.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/nfs/flexfilelayout/flexfilelayout.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 7d05089..0f1410c 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -182,17 +182,14 @@ static void _ff_layout_free_lseg(struct nfs4_ff_layout_segment *fls)
 
 static void ff_layout_sort_mirrors(struct nfs4_ff_layout_segment *fls)
 {
-	struct nfs4_ff_layout_mirror *tmp;
 	int i, j;
 
 	for (i = 0; i < fls->mirror_array_cnt - 1; i++) {
 		for (j = i + 1; j < fls->mirror_array_cnt; j++)
 			if (fls->mirror_array[i]->efficiency <
-			    fls->mirror_array[j]->efficiency) {
-				tmp = fls->mirror_array[i];
-				fls->mirror_array[i] = fls->mirror_array[j];
-				fls->mirror_array[j] = tmp;
-			}
+			    fls->mirror_array[j]->efficiency)
+				swap(fls->mirror_array[i],
+				     fls->mirror_array[j]);
 	}
 }
 
-- 
2.4.2


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

* Re: [PATCH 1/1 linux-next] pnfs/flexfiles: use swap() in ff_layout_sort_mirrors()
  2015-06-12 16:58 [PATCH 1/1 linux-next] pnfs/flexfiles: use swap() in ff_layout_sort_mirrors() Fabian Frederick
@ 2015-06-12 17:17 ` Joe Perches
  2015-06-14  5:23   ` Fabian Frederick
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2015-06-12 17:17 UTC (permalink / raw)
  To: Fabian Frederick
  Cc: linux-kernel, Julia Lawall, Trond Myklebust, Anna Schumaker, linux-nfs

On Fri, 2015-06-12 at 18:58 +0200, Fabian Frederick wrote:
> Use kernel.h macro definition.

A lot of these conversions seem to be for bubble sorts.
Maybe it'd be useful to add a generic one somewhere.

> diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
[]
> @@ -182,17 +182,14 @@ static void _ff_layout_free_lseg(struct nfs4_ff_layout_segment *fls)
>  
>  static void ff_layout_sort_mirrors(struct nfs4_ff_layout_segment *fls)
>  {
> -	struct nfs4_ff_layout_mirror *tmp;
>  	int i, j;
>  
>  	for (i = 0; i < fls->mirror_array_cnt - 1; i++) {
>  		for (j = i + 1; j < fls->mirror_array_cnt; j++)
>  			if (fls->mirror_array[i]->efficiency <
> -			    fls->mirror_array[j]->efficiency) {
> -				tmp = fls->mirror_array[i];
> -				fls->mirror_array[i] = fls->mirror_array[j];
> -				fls->mirror_array[j] = tmp;
> -			}
> +			    fls->mirror_array[j]->efficiency)
> +				swap(fls->mirror_array[i],
> +				     fls->mirror_array[j]);
>  	}
>  }
>  




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

* Re: [PATCH 1/1 linux-next] pnfs/flexfiles: use swap() in ff_layout_sort_mirrors()
  2015-06-12 17:17 ` Joe Perches
@ 2015-06-14  5:23   ` Fabian Frederick
  0 siblings, 0 replies; 3+ messages in thread
From: Fabian Frederick @ 2015-06-14  5:23 UTC (permalink / raw)
  To: Joe Perches
  Cc: Trond Myklebust, linux-nfs, linux-kernel, Julia Lawall, Anna Schumaker



> On 12 June 2015 at 19:17 Joe Perches <joe@perches.com> wrote:
>
>
> On Fri, 2015-06-12 at 18:58 +0200, Fabian Frederick wrote:
> > Use kernel.h macro definition.
>
> A lot of these conversions seem to be for bubble sorts.
> Maybe it'd be useful to add a generic one somewhere.

Of course but those swap() conversions already do some smooth cleanup.
btw it will be easier to find sort occurences and replace them if necessary.

Regards,
Fabian
>
> > diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c
> > b/fs/nfs/flexfilelayout/flexfilelayout.c
> []
> > @@ -182,17 +182,14 @@ static void _ff_layout_free_lseg(struct
> > nfs4_ff_layout_segment *fls)
> > 
> >  static void ff_layout_sort_mirrors(struct nfs4_ff_layout_segment *fls)
> >  {
> > -   struct nfs4_ff_layout_mirror *tmp;
> >     int i, j;
> > 
> >     for (i = 0; i < fls->mirror_array_cnt - 1; i++) {
> >             for (j = i + 1; j < fls->mirror_array_cnt; j++)
> >                     if (fls->mirror_array[i]->efficiency <
> > -                       fls->mirror_array[j]->efficiency) {
> > -                           tmp = fls->mirror_array[i];
> > -                           fls->mirror_array[i] = fls->mirror_array[j];
> > -                           fls->mirror_array[j] = tmp;
> > -                   }
> > +                       fls->mirror_array[j]->efficiency)
> > +                           swap(fls->mirror_array[i],
> > +                                fls->mirror_array[j]);
> >     }
> >  }
> > 
>
>
>

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

end of thread, other threads:[~2015-06-14  5:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12 16:58 [PATCH 1/1 linux-next] pnfs/flexfiles: use swap() in ff_layout_sort_mirrors() Fabian Frederick
2015-06-12 17:17 ` Joe Perches
2015-06-14  5:23   ` Fabian Frederick

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).