Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4e91672c76319aaed24ea3e784e238cf445c57cb
Commit:     4e91672c76319aaed24ea3e784e238cf445c57cb
Parent:     948730b0e39fb4cba4a5ed0fc40e0f017cce2dfa
Author:     Johannes Weiner <[EMAIL PROTECTED]>
AuthorDate: Sun Jul 15 23:41:25 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Mon Jul 16 09:05:50 2007 -0700

    Replace obscure constructs in fs/block_dev.c
    
    Replace some funky codepaths in fs/block_dev.c with cleaner versions of the
    affected places.
    
    [EMAIL PROTECTED]: fix return value]
    Signed-off-by: Johannes Weiner <[EMAIL PROTECTED]>
    Cc: Bjorn Steinbrink <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/block_dev.c |   50 ++++++++++++++++++++++++++++----------------------
 1 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index da5f051..75c47a2 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -872,7 +872,7 @@ static struct bd_holder *find_bd_holder(struct block_device 
*bdev,
  */
 static int add_bd_holder(struct block_device *bdev, struct bd_holder *bo)
 {
-       int ret;
+       int err;
 
        if (!bo)
                return -EINVAL;
@@ -880,15 +880,18 @@ static int add_bd_holder(struct block_device *bdev, 
struct bd_holder *bo)
        if (!bd_holder_grab_dirs(bdev, bo))
                return -EBUSY;
 
-       ret = add_symlink(bo->sdir, bo->sdev);
-       if (ret == 0) {
-               ret = add_symlink(bo->hdir, bo->hdev);
-               if (ret)
-                       del_symlink(bo->sdir, bo->sdev);
+       err = add_symlink(bo->sdir, bo->sdev);
+       if (err)
+               return err;
+
+       err = add_symlink(bo->hdir, bo->hdev);
+       if (err) {
+               del_symlink(bo->sdir, bo->sdev);
+               return err;
        }
-       if (ret == 0)
-               list_add_tail(&bo->list, &bdev->bd_holder_list);
-       return ret;
+
+       list_add_tail(&bo->list, &bdev->bd_holder_list);
+       return 0;
 }
 
 /**
@@ -946,7 +949,7 @@ static struct bd_holder *del_bd_holder(struct block_device 
*bdev,
 static int bd_claim_by_kobject(struct block_device *bdev, void *holder,
                                struct kobject *kobj)
 {
-       int res;
+       int err;
        struct bd_holder *bo, *found;
 
        if (!kobj)
@@ -957,21 +960,24 @@ static int bd_claim_by_kobject(struct block_device *bdev, 
void *holder,
                return -ENOMEM;
 
        mutex_lock(&bdev->bd_mutex);
-       res = bd_claim(bdev, holder);
-       if (res == 0) {
-               found = find_bd_holder(bdev, bo);
-               if (found == NULL) {
-                       res = add_bd_holder(bdev, bo);
-                       if (res)
-                               bd_release(bdev);
-               }
-       }
 
-       if (res || found)
+       err = bd_claim(bdev, holder);
+       if (err)
+               goto out;
+
+       found = find_bd_holder(bdev, bo);
+       if (found)
+               goto out;
+
+       err = add_bd_holder(bdev, bo);
+       if (err)
+               bd_release(bdev);
+
+out:
+       if (err || found)
                free_bd_holder(bo);
        mutex_unlock(&bdev->bd_mutex);
-
-       return res;
+       return err;
 }
 
 /**
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to