diff mbox series

[3/7] xfs: simplify xfs_attr_remove_args

Message ID 20210412133819.2618857-4-hch@lst.de (mailing list archive)
State Accepted
Headers show
Series [1/7] xfs: move the XFS_IFEXTENTS check into xfs_iread_extents | expand

Commit Message

Christoph Hellwig April 12, 2021, 1:38 p.m. UTC
Directly return from the subfunctions and avoid the error variable.  Also
remove the not really needed dp local variable.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_attr.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

Comments

Darrick J. Wong April 14, 2021, 12:06 a.m. UTC | #1
On Mon, Apr 12, 2021 at 03:38:15PM +0200, Christoph Hellwig wrote:
> Directly return from the subfunctions and avoid the error variable.  Also
> remove the not really needed dp local variable.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/libxfs/xfs_attr.c | 21 ++++++++-------------
>  1 file changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index fd61c67f573925..43ef85678cba6b 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -386,21 +386,16 @@ int
>  xfs_attr_remove_args(
>  	struct xfs_da_args      *args)
>  {
> -	struct xfs_inode	*dp = args->dp;
> -	int			error;
> +	if (!xfs_inode_hasattr(args->dp))
> +		return -ENOATTR;
>  
> -	if (!xfs_inode_hasattr(dp)) {
> -		error = -ENOATTR;
> -	} else if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) {
> -		ASSERT(dp->i_afp->if_flags & XFS_IFINLINE);
> -		error = xfs_attr_shortform_remove(args);
> -	} else if (xfs_attr_is_leaf(dp)) {
> -		error = xfs_attr_leaf_removename(args);
> -	} else {
> -		error = xfs_attr_node_removename(args);
> +	if (args->dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) {
> +		ASSERT(args->dp->i_afp->if_flags & XFS_IFINLINE);
> +		return xfs_attr_shortform_remove(args);
>  	}
> -
> -	return error;
> +	if (xfs_attr_is_leaf(args->dp))
> +		return xfs_attr_leaf_removename(args);
> +	return xfs_attr_node_removename(args);
>  }
>  
>  /*
> -- 
> 2.30.1
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index fd61c67f573925..43ef85678cba6b 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -386,21 +386,16 @@  int
 xfs_attr_remove_args(
 	struct xfs_da_args      *args)
 {
-	struct xfs_inode	*dp = args->dp;
-	int			error;
+	if (!xfs_inode_hasattr(args->dp))
+		return -ENOATTR;
 
-	if (!xfs_inode_hasattr(dp)) {
-		error = -ENOATTR;
-	} else if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) {
-		ASSERT(dp->i_afp->if_flags & XFS_IFINLINE);
-		error = xfs_attr_shortform_remove(args);
-	} else if (xfs_attr_is_leaf(dp)) {
-		error = xfs_attr_leaf_removename(args);
-	} else {
-		error = xfs_attr_node_removename(args);
+	if (args->dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) {
+		ASSERT(args->dp->i_afp->if_flags & XFS_IFINLINE);
+		return xfs_attr_shortform_remove(args);
 	}
-
-	return error;
+	if (xfs_attr_is_leaf(args->dp))
+		return xfs_attr_leaf_removename(args);
+	return xfs_attr_node_removename(args);
 }
 
 /*