Author: pfg
Date: Tue Jun  7 18:23:22 2016
New Revision: 301560
URL: https://svnweb.freebsd.org/changeset/base/301560

Log:
  ext2fs: rearrange ext4_bmapext().
  
  While here assign error a bit later.
  
  Reviewed by:  Damjan Jovanovich
  Obtained from:        NetBSD

Modified:
  head/sys/fs/ext2fs/ext2_bmap.c

Modified: head/sys/fs/ext2fs/ext2_bmap.c
==============================================================================
--- head/sys/fs/ext2fs/ext2_bmap.c      Tue Jun  7 17:08:34 2016        
(r301559)
+++ head/sys/fs/ext2fs/ext2_bmap.c      Tue Jun  7 18:23:22 2016        
(r301560)
@@ -97,7 +97,7 @@ ext4_bmapext(struct vnode *vp, int32_t b
        struct ext4_extent *ep;
        struct ext4_extent_path path = { .ep_bp = NULL };
        daddr_t lbn;
-       int error = 0;
+       int error;
 
        ip = VTOI(vp);
        fs = ip->i_e2fs;
@@ -105,9 +105,9 @@ ext4_bmapext(struct vnode *vp, int32_t b
 
        if (runp != NULL)
                *runp = 0;
-
        if (runb != NULL)
                *runb = 0;
+       error = 0;
 
        ext4_ext_find_extent(fs, ip, lbn, &path);
        if (path.ep_is_sparse) {
@@ -118,27 +118,26 @@ ext4_bmapext(struct vnode *vp, int32_t b
                if (runb != NULL)
                        *runb = lbn - path.ep_sparse_ext.e_blk;
        } else {
-               ep = path.ep_ext;
-               if (ep == NULL)
+               if ( path.ep_ext == NULL) {
                        error = EIO;
-               else {
-                       *bnp = fsbtodb(fs, lbn - ep->e_blk +
-                           (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32));
-
-                       if (*bnp == 0)
-                               *bnp = -1;
-
-                       if (runp != NULL)
-                               *runp = ep->e_len - (lbn - ep->e_blk) - 1;
-                       if (runb != NULL)
-                               *runb = lbn - ep->e_blk;
+                       goto out;
                }
+               ep = path.ep_ext;
+               *bnp = fsbtodb(fs, lbn - ep->e_blk +
+                   (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32));
+
+               if (*bnp == 0)
+                       *bnp = -1;
+
+               if (runp != NULL)
+                       *runp = ep->e_len - (lbn - ep->e_blk) - 1;
+               if (runb != NULL)
+                       *runb = lbn - ep->e_blk;
        }
 
-       if (path.ep_bp != NULL) {
+out:
+       if (path.ep_bp != NULL)
                brelse(path.ep_bp);
-               path.ep_bp = NULL;
-       }
 
        return (error);
 }
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to