diff mbox series

[v2,6/7] xfs: code cleanup in xfs_attr_leaf_entsize_{remote,local}

Message ID 1600342728-21149-7-git-send-email-kaixuxia@tencent.com (mailing list archive)
State Superseded
Headers show
Series xfs: random fixes and code cleanup | expand

Commit Message

Kaixu Xia Sept. 17, 2020, 11:38 a.m. UTC
From: Kaixu Xia <kaixuxia@tencent.com>

Cleanup the typedef usage, the unnecessary parentheses, the unnecessary
backslash and use the open-coded round_up call in
xfs_attr_leaf_entsize_{remote,local}.

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
---
 fs/xfs/libxfs/xfs_da_format.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Darrick J. Wong Sept. 17, 2020, 6:19 p.m. UTC | #1
On Thu, Sep 17, 2020 at 07:38:47PM +0800, xiakaixu1987@gmail.com wrote:
> From: Kaixu Xia <kaixuxia@tencent.com>
> 
> Cleanup the typedef usage, the unnecessary parentheses, the unnecessary
> backslash and use the open-coded round_up call in
> xfs_attr_leaf_entsize_{remote,local}.
> 
> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>

Seems alright,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_da_format.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h
> index b40a4e80f5ee..09f0f5d42728 100644
> --- a/fs/xfs/libxfs/xfs_da_format.h
> +++ b/fs/xfs/libxfs/xfs_da_format.h
> @@ -746,14 +746,14 @@ xfs_attr3_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
>   */
>  static inline int xfs_attr_leaf_entsize_remote(int nlen)
>  {
> -	return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \
> -		XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
> +	return round_up(sizeof(struct xfs_attr_leaf_name_remote) - 1 + nlen,
> +			XFS_ATTR_LEAF_NAME_ALIGN);
>  }
>  
>  static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
>  {
> -	return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) +
> -		XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
> +	return round_up(sizeof(struct xfs_attr_leaf_name_local) - 1 + nlen + vlen,
> +			XFS_ATTR_LEAF_NAME_ALIGN);
>  }
>  
>  static inline int xfs_attr_leaf_entsize_local_max(int bsize)
> -- 
> 2.20.0
>
Christoph Hellwig Sept. 19, 2020, 6:29 a.m. UTC | #2
On Thu, Sep 17, 2020 at 07:38:47PM +0800, xiakaixu1987@gmail.com wrote:
>  static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
>  {
> -	return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) +
> -		XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
> +	return round_up(sizeof(struct xfs_attr_leaf_name_local) - 1 + nlen + vlen,

Please avoid the overly long line here.
Kaixu Xia Sept. 23, 2020, 3:21 a.m. UTC | #3
On 2020/9/19 14:29, Christoph Hellwig wrote:
> On Thu, Sep 17, 2020 at 07:38:47PM +0800, xiakaixu1987@gmail.com wrote:
>>  static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
>>  {
>> -	return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) +
>> -		XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
>> +	return round_up(sizeof(struct xfs_attr_leaf_name_local) - 1 + nlen + vlen,
> 
> Please avoid the overly long line here.

Okay, will fix it in the next version.

Thanks,
Kaixu
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h
index b40a4e80f5ee..09f0f5d42728 100644
--- a/fs/xfs/libxfs/xfs_da_format.h
+++ b/fs/xfs/libxfs/xfs_da_format.h
@@ -746,14 +746,14 @@  xfs_attr3_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
  */
 static inline int xfs_attr_leaf_entsize_remote(int nlen)
 {
-	return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \
-		XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
+	return round_up(sizeof(struct xfs_attr_leaf_name_remote) - 1 + nlen,
+			XFS_ATTR_LEAF_NAME_ALIGN);
 }
 
 static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
 {
-	return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) +
-		XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
+	return round_up(sizeof(struct xfs_attr_leaf_name_local) - 1 + nlen + vlen,
+			XFS_ATTR_LEAF_NAME_ALIGN);
 }
 
 static inline int xfs_attr_leaf_entsize_local_max(int bsize)