Skip to content

Commit

Permalink
xfs: global error sign conversion
Browse files Browse the repository at this point in the history
Convert all the errors the core XFs code to negative error signs
like the rest of the kernel and remove all the sign conversion we
do in the interface layers.

Errors for conversion (and comparison) found via searches like:

$ git grep " E" fs/xfs
$ git grep "return E" fs/xfs
$ git grep " E[A-Z].*;$" fs/xfs

Negation points found via searches like:

$ git grep "= -[a-z,A-Z]" fs/xfs
$ git grep "return -[a-z,A-D,F-Z]" fs/xfs
$ git grep " -[a-z].*;" fs/xfs

[ with some bits I missed from Brian Foster ]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
  • Loading branch information
Dave Chinner authored and Dave Chinner committed Jun 25, 2014
1 parent 30f712c commit 2451337
Show file tree
Hide file tree
Showing 67 changed files with 882 additions and 887 deletions.
20 changes: 10 additions & 10 deletions fs/xfs/libxfs/xfs_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,9 @@ xfs_agfl_read_verify(
return;

if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF))
xfs_buf_ioerror(bp, EFSBADCRC);
xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_agfl_verify(bp))
xfs_buf_ioerror(bp, EFSCORRUPTED);
xfs_buf_ioerror(bp, -EFSCORRUPTED);

if (bp->b_error)
xfs_verifier_error(bp);
Expand All @@ -503,7 +503,7 @@ xfs_agfl_write_verify(
return;

if (!xfs_agfl_verify(bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED);
xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return;
}
Expand Down Expand Up @@ -559,7 +559,7 @@ xfs_alloc_update_counters(
xfs_trans_agblocks_delta(tp, len);
if (unlikely(be32_to_cpu(agf->agf_freeblks) >
be32_to_cpu(agf->agf_length)))
return EFSCORRUPTED;
return -EFSCORRUPTED;

xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS);
return 0;
Expand Down Expand Up @@ -2234,11 +2234,11 @@ xfs_agf_read_verify(

if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF))
xfs_buf_ioerror(bp, EFSBADCRC);
xfs_buf_ioerror(bp, -EFSBADCRC);
else if (XFS_TEST_ERROR(!xfs_agf_verify(mp, bp), mp,
XFS_ERRTAG_ALLOC_READ_AGF,
XFS_RANDOM_ALLOC_READ_AGF))
xfs_buf_ioerror(bp, EFSCORRUPTED);
xfs_buf_ioerror(bp, -EFSCORRUPTED);

if (bp->b_error)
xfs_verifier_error(bp);
Expand All @@ -2252,7 +2252,7 @@ xfs_agf_write_verify(
struct xfs_buf_log_item *bip = bp->b_fspriv;

if (!xfs_agf_verify(mp, bp)) {
xfs_buf_ioerror(bp, EFSCORRUPTED);
xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return;
}
Expand Down Expand Up @@ -2601,11 +2601,11 @@ xfs_free_extent(
*/
args.agno = XFS_FSB_TO_AGNO(args.mp, bno);
if (args.agno >= args.mp->m_sb.sb_agcount)
return EFSCORRUPTED;
return -EFSCORRUPTED;

args.agbno = XFS_FSB_TO_AGBNO(args.mp, bno);
if (args.agbno >= args.mp->m_sb.sb_agblocks)
return EFSCORRUPTED;
return -EFSCORRUPTED;

args.pag = xfs_perag_get(args.mp, args.agno);
ASSERT(args.pag);
Expand All @@ -2617,7 +2617,7 @@ xfs_free_extent(
/* validate the extent size is legal now we have the agf locked */
if (args.agbno + len >
be32_to_cpu(XFS_BUF_TO_AGF(args.agbp)->agf_length)) {
error = EFSCORRUPTED;
error = -EFSCORRUPTED;
goto error0;
}

Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/libxfs/xfs_alloc_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ xfs_allocbt_read_verify(
struct xfs_buf *bp)
{
if (!xfs_btree_sblock_verify_crc(bp))
xfs_buf_ioerror(bp, EFSBADCRC);
xfs_buf_ioerror(bp, -EFSBADCRC);
else if (!xfs_allocbt_verify(bp))
xfs_buf_ioerror(bp, EFSCORRUPTED);
xfs_buf_ioerror(bp, -EFSCORRUPTED);

if (bp->b_error) {
trace_xfs_btree_corrupt(bp, _RET_IP_);
Expand All @@ -371,7 +371,7 @@ xfs_allocbt_write_verify(
{
if (!xfs_allocbt_verify(bp)) {
trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_buf_ioerror(bp, EFSCORRUPTED);
xfs_buf_ioerror(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return;
}
Expand Down
50 changes: 25 additions & 25 deletions fs/xfs/libxfs/xfs_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ xfs_attr_args_init(
{

if (!name)
return EINVAL;
return -EINVAL;

memset(args, 0, sizeof(*args));
args->geo = dp->i_mount->m_attr_geo;
Expand All @@ -95,7 +95,7 @@ xfs_attr_args_init(
args->name = name;
args->namelen = strlen((const char *)name);
if (args->namelen >= MAXNAMELEN)
return EFAULT; /* match IRIX behaviour */
return -EFAULT; /* match IRIX behaviour */

args->hashval = xfs_da_hashname(args->name, args->namelen);
return 0;
Expand Down Expand Up @@ -131,10 +131,10 @@ xfs_attr_get(
XFS_STATS_INC(xs_attr_get);

if (XFS_FORCED_SHUTDOWN(ip->i_mount))
return EIO;
return -EIO;

if (!xfs_inode_hasattr(ip))
return ENOATTR;
return -ENOATTR;

error = xfs_attr_args_init(&args, ip, name, flags);
if (error)
Expand All @@ -145,7 +145,7 @@ xfs_attr_get(

lock_mode = xfs_ilock_attr_map_shared(ip);
if (!xfs_inode_hasattr(ip))
error = ENOATTR;
error = -ENOATTR;
else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL)
error = xfs_attr_shortform_getvalue(&args);
else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK))
Expand All @@ -155,7 +155,7 @@ xfs_attr_get(
xfs_iunlock(ip, lock_mode);

*valuelenp = args.valuelen;
return error == EEXIST ? 0 : error;
return error == -EEXIST ? 0 : error;
}

/*
Expand Down Expand Up @@ -213,7 +213,7 @@ xfs_attr_set(
XFS_STATS_INC(xs_attr_set);

if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return EIO;
return -EIO;

error = xfs_attr_args_init(&args, dp, name, flags);
if (error)
Expand Down Expand Up @@ -304,7 +304,7 @@ xfs_attr_set(
* the inode.
*/
error = xfs_attr_shortform_addname(&args);
if (error != ENOSPC) {
if (error != -ENOSPC) {
/*
* Commit the shortform mods, and we're done.
* NOTE: this is also the error path (EEXIST, etc).
Expand Down Expand Up @@ -419,10 +419,10 @@ xfs_attr_remove(
XFS_STATS_INC(xs_attr_remove);

if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return EIO;
return -EIO;

if (!xfs_inode_hasattr(dp))
return ENOATTR;
return -ENOATTR;

error = xfs_attr_args_init(&args, dp, name, flags);
if (error)
Expand Down Expand Up @@ -477,7 +477,7 @@ xfs_attr_remove(
xfs_trans_ijoin(args.trans, dp, 0);

if (!xfs_inode_hasattr(dp)) {
error = ENOATTR;
error = -ENOATTR;
} else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
ASSERT(dp->i_afp->if_flags & XFS_IFINLINE);
error = xfs_attr_shortform_remove(&args);
Expand Down Expand Up @@ -534,9 +534,9 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
trace_xfs_attr_sf_addname(args);

retval = xfs_attr_shortform_lookup(args);
if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) {
return retval;
} else if (retval == EEXIST) {
} else if (retval == -EEXIST) {
if (args->flags & ATTR_CREATE)
return retval;
retval = xfs_attr_shortform_remove(args);
Expand All @@ -545,14 +545,14 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)

if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX ||
args->valuelen >= XFS_ATTR_SF_ENTSIZE_MAX)
return ENOSPC;
return -ENOSPC;

newsize = XFS_ATTR_SF_TOTSIZE(args->dp);
newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen);

forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize);
if (!forkoff)
return ENOSPC;
return -ENOSPC;

xfs_attr_shortform_add(args, forkoff);
return 0;
Expand Down Expand Up @@ -592,10 +592,10 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
* the given flags produce an error or call for an atomic rename.
*/
retval = xfs_attr3_leaf_lookup_int(bp, args);
if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) {
xfs_trans_brelse(args->trans, bp);
return retval;
} else if (retval == EEXIST) {
} else if (retval == -EEXIST) {
if (args->flags & ATTR_CREATE) { /* pure create op */
xfs_trans_brelse(args->trans, bp);
return retval;
Expand Down Expand Up @@ -626,7 +626,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
* if required.
*/
retval = xfs_attr3_leaf_add(bp, args);
if (retval == ENOSPC) {
if (retval == -ENOSPC) {
/*
* Promote the attribute list to the Btree format, then
* Commit that transaction so that the node_addname() call
Expand Down Expand Up @@ -795,7 +795,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
return error;

error = xfs_attr3_leaf_lookup_int(bp, args);
if (error == ENOATTR) {
if (error == -ENOATTR) {
xfs_trans_brelse(args->trans, bp);
return error;
}
Expand Down Expand Up @@ -850,7 +850,7 @@ xfs_attr_leaf_get(xfs_da_args_t *args)
return error;

error = xfs_attr3_leaf_lookup_int(bp, args);
if (error != EEXIST) {
if (error != -EEXIST) {
xfs_trans_brelse(args->trans, bp);
return error;
}
Expand Down Expand Up @@ -906,9 +906,9 @@ xfs_attr_node_addname(xfs_da_args_t *args)
goto out;
blk = &state->path.blk[ state->path.active-1 ];
ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) {
goto out;
} else if (retval == EEXIST) {
} else if (retval == -EEXIST) {
if (args->flags & ATTR_CREATE)
goto out;

Expand All @@ -933,7 +933,7 @@ xfs_attr_node_addname(xfs_da_args_t *args)
}

retval = xfs_attr3_leaf_add(blk->bp, state->args);
if (retval == ENOSPC) {
if (retval == -ENOSPC) {
if (state->path.active == 1) {
/*
* Its really a single leaf node, but it had
Expand Down Expand Up @@ -1168,7 +1168,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
* Search to see if name exists, and get back a pointer to it.
*/
error = xfs_da3_node_lookup_int(state, &retval);
if (error || (retval != EEXIST)) {
if (error || (retval != -EEXIST)) {
if (error == 0)
error = retval;
goto out;
Expand Down Expand Up @@ -1431,7 +1431,7 @@ xfs_attr_node_get(xfs_da_args_t *args)
error = xfs_da3_node_lookup_int(state, &retval);
if (error) {
retval = error;
} else if (retval == EEXIST) {
} else if (retval == -EEXIST) {
blk = &state->path.blk[ state->path.active-1 ];
ASSERT(blk->bp != NULL);
ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
Expand Down
Loading

0 comments on commit 2451337

Please sign in to comment.