xfs: simplify if-else condition in xfs_validate_new_dalign
authorZeng Heng <zengheng4@huawei.com>
Sun, 18 Sep 2022 20:49:14 +0000 (06:49 +1000)
committerDave Chinner <david@fromorbit.com>
Sun, 18 Sep 2022 20:49:14 +0000 (06:49 +1000)
"else" is not generally useful after a return,
so remove them which makes if condition a bit
more clear.

There is no logical changes.

Signed-off-by: Zeng Heng <zengheng4@huawei.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_mount.c

index f10c88cee116e17619a9ca03f08f87c998180ddd..e8bb3c2e847e1ad14769ccf2f285df0cb56929db 100644 (file)
@@ -300,26 +300,28 @@ xfs_validate_new_dalign(
        "alignment check failed: sunit/swidth vs. blocksize(%d)",
                        mp->m_sb.sb_blocksize);
                return -EINVAL;
-       } else {
-               /*
-                * Convert the stripe unit and width to FSBs.
-                */
-               mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign);
-               if (mp->m_dalign && (mp->m_sb.sb_agblocks % mp->m_dalign)) {
-                       xfs_warn(mp,
-               "alignment check failed: sunit/swidth vs. agsize(%d)",
-                                mp->m_sb.sb_agblocks);
-                       return -EINVAL;
-               } else if (mp->m_dalign) {
-                       mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth);
-               } else {
-                       xfs_warn(mp,
-               "alignment check failed: sunit(%d) less than bsize(%d)",
-                                mp->m_dalign, mp->m_sb.sb_blocksize);
-                       return -EINVAL;
-               }
        }
 
+       /*
+        * Convert the stripe unit and width to FSBs.
+        */
+       mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign);
+       if (mp->m_dalign && (mp->m_sb.sb_agblocks % mp->m_dalign)) {
+               xfs_warn(mp,
+       "alignment check failed: sunit/swidth vs. agsize(%d)",
+                       mp->m_sb.sb_agblocks);
+               return -EINVAL;
+       }
+
+       if (!mp->m_dalign) {
+               xfs_warn(mp,
+       "alignment check failed: sunit(%d) less than bsize(%d)",
+                       mp->m_dalign, mp->m_sb.sb_blocksize);
+               return -EINVAL;
+       }
+
+       mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth);
+
        if (!xfs_has_dalign(mp)) {
                xfs_warn(mp,
 "cannot change alignment: superblock does not support data alignment");