Commit f3e93d95 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: clean up the ATTR_REPLACE checks

Remove superflous braces, elses after return statements and use a goto
label to merge common error handling.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 5a3930e2
...@@ -423,9 +423,9 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) ...@@ -423,9 +423,9 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
trace_xfs_attr_sf_addname(args); trace_xfs_attr_sf_addname(args);
retval = xfs_attr_shortform_lookup(args); retval = xfs_attr_shortform_lookup(args);
if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { if (retval == -ENOATTR && (args->flags & ATTR_REPLACE))
return retval; return retval;
} else if (retval == -EEXIST) { if (retval == -EEXIST) {
if (args->flags & ATTR_CREATE) if (args->flags & ATTR_CREATE)
return retval; return retval;
retval = xfs_attr_shortform_remove(args); retval = xfs_attr_shortform_remove(args);
...@@ -489,14 +489,11 @@ xfs_attr_leaf_addname( ...@@ -489,14 +489,11 @@ xfs_attr_leaf_addname(
* the given flags produce an error or call for an atomic rename. * the given flags produce an error or call for an atomic rename.
*/ */
retval = xfs_attr3_leaf_lookup_int(bp, args); retval = xfs_attr3_leaf_lookup_int(bp, args);
if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { if (retval == -ENOATTR && (args->flags & ATTR_REPLACE))
xfs_trans_brelse(args->trans, bp); goto out_brelse;
return retval; if (retval == -EEXIST) {
} else if (retval == -EEXIST) { if (args->flags & ATTR_CREATE) /* pure create op */
if (args->flags & ATTR_CREATE) { /* pure create op */ goto out_brelse;
xfs_trans_brelse(args->trans, bp);
return retval;
}
trace_xfs_attr_leaf_replace(args); trace_xfs_attr_leaf_replace(args);
...@@ -637,6 +634,9 @@ xfs_attr_leaf_addname( ...@@ -637,6 +634,9 @@ xfs_attr_leaf_addname(
error = xfs_attr3_leaf_clearflag(args); error = xfs_attr3_leaf_clearflag(args);
} }
return error; return error;
out_brelse:
xfs_trans_brelse(args->trans, bp);
return retval;
} }
/* /*
...@@ -763,9 +763,9 @@ xfs_attr_node_addname( ...@@ -763,9 +763,9 @@ xfs_attr_node_addname(
goto out; goto out;
blk = &state->path.blk[ state->path.active-1 ]; blk = &state->path.blk[ state->path.active-1 ];
ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) { if (retval == -ENOATTR && (args->flags & ATTR_REPLACE))
goto out; goto out;
} else if (retval == -EEXIST) { if (retval == -EEXIST) {
if (args->flags & ATTR_CREATE) if (args->flags & ATTR_CREATE)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment