All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: fix returnvar.cocci warnings
@ 2017-01-26  9:20 Julia Lawall
  2017-01-26 18:30 ` Darrick J. Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2017-01-26  9:20 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, linux-kernel, kbuild-all

Remove unneeded variable used to store return value.

Generated by: scripts/coccinelle/misc/returnvar.cocci

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

Is it correct to be returning 0 in the level == 0 case?

 dabtree.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

--- a/fs/xfs/scrub/dabtree.c
+++ b/fs/xfs/scrub/dabtree.c
@@ -96,7 +96,6 @@ xfs_scrub_da_btree_hash(
 	struct xfs_da_node_entry	*btree;
 	xfs_dahash_t			hash;
 	xfs_dahash_t			parent_hash;
-	int				error = 0;

 	/* Is this hash in order? */
 	hash = be32_to_cpu(*hashp);
@@ -104,7 +103,7 @@ xfs_scrub_da_btree_hash(
 	ds->hashes[level] = hash;

 	if (level == 0)
-		return error;
+		return 0;

 	/* Is this hash no larger than the parent hash? */
 	blks = ds->state->path.blk;
@@ -112,7 +111,7 @@ xfs_scrub_da_btree_hash(
 	parent_hash = be32_to_cpu(btree->hashval);
 	XFS_SCRUB_DA_CHECK(ds, hash <= parent_hash);

-	return error;
+	return 0;
 }

 /* Scrub a da btree pointer. */
@@ -122,12 +121,10 @@ xfs_scrub_da_btree_ptr(
 	int				level,
 	xfs_dablk_t			blkno)
 {
-	int				error = 0;
-
 	XFS_SCRUB_DA_CHECK(ds, blkno >= ds->lowest);
 	XFS_SCRUB_DA_CHECK(ds, ds->highest == 0 || blkno < ds->highest);

-	return error;
+	return 0;
 }

 /*

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] xfs: fix returnvar.cocci warnings
  2017-01-26  9:20 [PATCH] xfs: fix returnvar.cocci warnings Julia Lawall
@ 2017-01-26 18:30 ` Darrick J. Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2017-01-26 18:30 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-xfs, linux-kernel, kbuild-all

On Thu, Jan 26, 2017 at 10:20:58AM +0100, Julia Lawall wrote:
> Remove unneeded variable used to store return value.
> 
> Generated by: scripts/coccinelle/misc/returnvar.cocci
> 
> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> ---
> 
> Is it correct to be returning 0 in the level == 0 case?

Yes, because level == 0 is the root node for xfs dir/attr btree cursors
(which is confusing since level == 0 are leaf nodes for the regular xfs
btree cursors).  Therefore if level == 0 we're at the root and there are
no parent hash values to check.

That said, you're absolutely right that we don't need the intermediate
variable in either function.

--D

> 
>  dabtree.c |    9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> --- a/fs/xfs/scrub/dabtree.c
> +++ b/fs/xfs/scrub/dabtree.c
> @@ -96,7 +96,6 @@ xfs_scrub_da_btree_hash(
>  	struct xfs_da_node_entry	*btree;
>  	xfs_dahash_t			hash;
>  	xfs_dahash_t			parent_hash;
> -	int				error = 0;
> 
>  	/* Is this hash in order? */
>  	hash = be32_to_cpu(*hashp);
> @@ -104,7 +103,7 @@ xfs_scrub_da_btree_hash(
>  	ds->hashes[level] = hash;
> 
>  	if (level == 0)
> -		return error;
> +		return 0;
> 
>  	/* Is this hash no larger than the parent hash? */
>  	blks = ds->state->path.blk;
> @@ -112,7 +111,7 @@ xfs_scrub_da_btree_hash(
>  	parent_hash = be32_to_cpu(btree->hashval);
>  	XFS_SCRUB_DA_CHECK(ds, hash <= parent_hash);
> 
> -	return error;
> +	return 0;
>  }
> 
>  /* Scrub a da btree pointer. */
> @@ -122,12 +121,10 @@ xfs_scrub_da_btree_ptr(
>  	int				level,
>  	xfs_dablk_t			blkno)
>  {
> -	int				error = 0;
> -
>  	XFS_SCRUB_DA_CHECK(ds, blkno >= ds->lowest);
>  	XFS_SCRUB_DA_CHECK(ds, ds->highest == 0 || blkno < ds->highest);
> 
> -	return error;
> +	return 0;
>  }
> 
>  /*
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-26 18:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-26  9:20 [PATCH] xfs: fix returnvar.cocci warnings Julia Lawall
2017-01-26 18:30 ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.