Re: [PATCH v2 1/2] xfs: Fix compiler warning in xfs_attr_node_removename_setup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 7/27/20 8:46 AM, Darrick J. Wong wrote:
On Sun, Jul 26, 2020 at 07:26:07PM -0700, Allison Collins wrote:
Fix compiler warning for variable 'blk' set but not used in
xfs_attr_node_removename_setup.  blk is used only in an ASSERT so only
declare blk when DEBUG is set.

Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: Allison Collins <allison.henderson@xxxxxxxxxx>
---
  fs/xfs/libxfs/xfs_attr.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index d4583a0..5168d32 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -1174,7 +1174,9 @@ int xfs_attr_node_removename_setup(
  	struct xfs_da_state	**state)
  {
  	int			error;
+#ifdef DEBUG
  	struct xfs_da_state_blk	*blk;
+#endif

But now a non-DEBUG compilation will trip over the assignment to blk:

	blk = &(*state)->path.blk[(*state)->path.active - 1];

that comes just before the asserts, right?

	ASSERT((*state)->path.blk[(*state)->path.active - 1].bp != NULL);
	ASSERT((*state)->path.blk[(*state)->path.active - 1].magic ==
		XFS_ATTR_LEAF_MAGIC);

In the end you probably just want to encode the accessor logic in the
assert body so the whole thing just disappears entirely.
Are you sure you'd rather have it that way, then once up in the declaration? Like this:

#ifdef DEBUG
struct xfs_da_state_blk *blk = &(*state)->path.blk[(*state)->path.active - 1];
#endif


--D

error = xfs_attr_node_hasname(args, state);
  	if (error != -EEXIST)
--
2.7.4




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux