xfs: combine two if statements with same condition
diff mbox series

Message ID 1585794394-31041-1-git-send-email-kaixuxia@tencent.com
State Superseded
Headers show
Series
  • xfs: combine two if statements with same condition
Related show

Commit Message

kaixuxia April 2, 2020, 2:26 a.m. UTC
From: Kaixu Xia <kaixuxia@tencent.com>

The two if statements have same condition, and the mask value
does not change in xfs_setattr_nonsize(), so combine them.

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
---
 fs/xfs/xfs_iops.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

Chaitanya Kulkarni April 2, 2020, 4:42 a.m. UTC | #1
On 4/1/20 7:26 PM, xiakaixu1987@gmail.com wrote:
> From: Kaixu Xia <kaixuxia@tencent.com>
>
> The two if statements have same condition, and the mask value
> does not change in xfs_setattr_nonsize(), so combine them.
>
> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>

Prior to the commit c4ed4243c40f ("xfs: split xfs_setattr")
xfs_setattr() had truncate

handling in between two identical changing file ownership ifs.  Since
then truncate code is moved

out of xfs_setattr() and mask value stays the same in the first if, it
make sense to combine these

two ifs. Looks good to me.


Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Christoph Hellwig April 2, 2020, 7:49 a.m. UTC | #2
On Thu, Apr 02, 2020 at 10:26:34AM +0800, xiakaixu1987@gmail.com wrote:
> From: Kaixu Xia <kaixuxia@tencent.com>
> 
> The two if statements have same condition, and the mask value
> does not change in xfs_setattr_nonsize(), so combine them.
> 
> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Patch
diff mbox series

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index f7a99b3..e348145 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -738,12 +738,7 @@ 
 			if (error)	/* out of quota */
 				goto out_cancel;
 		}
-	}
 
-	/*
-	 * Change file ownership.  Must be the owner or privileged.
-	 */
-	if (mask & (ATTR_UID|ATTR_GID)) {
 		/*
 		 * CAP_FSETID overrides the following restrictions:
 		 *