]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
[GFS2] Add consts to glock sorting function
authorSteven Whitehouse <swhiteho@redhat.com>
Sat, 9 Sep 2006 21:07:05 +0000 (17:07 -0400)
committerSteven Whitehouse <swhiteho@redhat.com>
Sat, 9 Sep 2006 21:07:05 +0000 (17:07 -0400)
Add back the consts which were casted away in the glock sorting
function. Also add early exit code.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/glock.c

index 8abfefe4efd4a82b7e5cb29bdc2230c27acfedab..e941183bbcdb2ac9edb7a60cfa1a8f4b65963234 100644 (file)
@@ -1494,26 +1494,20 @@ int gfs2_glock_nq_num(struct gfs2_sbd *sdp, u64 number,
 
 static int glock_compare(const void *arg_a, const void *arg_b)
 {
-       struct gfs2_holder *gh_a = *(struct gfs2_holder **)arg_a;
-       struct gfs2_holder *gh_b = *(struct gfs2_holder **)arg_b;
-       struct lm_lockname *a = &gh_a->gh_gl->gl_name;
-       struct lm_lockname *b = &gh_b->gh_gl->gl_name;
-       int ret = 0;
+       const struct gfs2_holder *gh_a = *(const struct gfs2_holder **)arg_a;
+       const struct gfs2_holder *gh_b = *(const struct gfs2_holder **)arg_b;
+       const struct lm_lockname *a = &gh_a->gh_gl->gl_name;
+       const struct lm_lockname *b = &gh_b->gh_gl->gl_name;
 
        if (a->ln_number > b->ln_number)
-               ret = 1;
-       else if (a->ln_number < b->ln_number)
-               ret = -1;
-       else {
-               if (gh_a->gh_state == LM_ST_SHARED &&
-                   gh_b->gh_state == LM_ST_EXCLUSIVE)
-                       ret = 1;
-               else if (!(gh_a->gh_flags & GL_LOCAL_EXCL) &&
-                        (gh_b->gh_flags & GL_LOCAL_EXCL))
-                       ret = 1;
-       }
-
-       return ret;
+               return 1;
+       if (a->ln_number < b->ln_number)
+               return -1;
+       if (gh_a->gh_state == LM_ST_SHARED && gh_b->gh_state == LM_ST_EXCLUSIVE)
+               return 1;
+       if (!(gh_a->gh_flags & GL_LOCAL_EXCL) && (gh_b->gh_flags & GL_LOCAL_EXCL))
+               return 1;
+       return 0;
 }
 
 /**