Skip to contentSkip to conversation

xfs: Fix compiler warnings

PATCH Superseded Allison Collins 2 participants 8 messages Jul 27, 2020 XFS filesystem

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover xfs: Fix compiler warnings

Some variables added in the delayed attr series were only used in ASSERT checks. This caused some compiler warnings. This is only declare them when DEBUG is set

Allison Collins (2):
xfs: Fix compiler warning in xfs_attr_node_removename_setup
xfs: Fix compiler warning in xfs_attr_shortform_add

 fs/xfs/libxfs/xfs_attr.c      | 2 ++
 fs/xfs/libxfs/xfs_attr_leaf.c | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#1 lore raw

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

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.

---
 fs/xfs/libxfs/xfs_attr.c | 2 ++
 1 file changed, 2 insertions(+)
fs/xfs/libxfs/xfs_attr.c +2 -0
index d4583a0..5168d32 100644
@@ -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
 
 	error = xfs_attr_node_hasname(args, state);
 	if (error != -EEXIST)
Signature · 1 line
2.7.4
#2 lore raw

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

Quoted 15 lines · Allison Collins

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.

---
 fs/xfs/libxfs/xfs_attr.c | 2 ++
 1 file changed, 2 insertions(+)
fs/xfs/libxfs/xfs_attr.c +0 -0
index d4583a0..5168d32 100644

fs/xfs/libxfs/xfs_attr.c int xfs_attr_node_removename_setup( · line 1179

Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +2 -0
@@ -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.

--D

Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +0 -0
 	error = xfs_attr_node_hasname(args, state);
 	if (error != -EEXIST)
Signature · 1 line
2.7.4
#3 lore raw

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

Quoted 27 lines · Darrick J. Wong
Quoted 15 lines · Allison Collins

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.

---
  fs/xfs/libxfs/xfs_attr.c | 2 ++
  1 file changed, 2 insertions(+)
fs/xfs/libxfs/xfs_attr.c +0 -0
index d4583a0..5168d32 100644

fs/xfs/libxfs/xfs_attr.c int xfs_attr_node_removename_setup( · line 1179

Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +2 -0
@@ -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];
Quoted 8 lines

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.

Alrighty, will fix

Allison

Quoted 9 lines

--D

Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +0 -0
  	error = xfs_attr_node_hasname(args, state);
  	if (error != -EEXIST)
Signature · 1 line
2.7.4
#4 lore raw

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

In reply to Darrick J. Wong
Quoted 27 lines · Darrick J. Wong
Quoted 15 lines · Allison Collins

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.

---
  fs/xfs/libxfs/xfs_attr.c | 2 ++
  1 file changed, 2 insertions(+)
fs/xfs/libxfs/xfs_attr.c +0 -0
index d4583a0..5168d32 100644

fs/xfs/libxfs/xfs_attr.c int xfs_attr_node_removename_setup( · line 1179

Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +2 -0
@@ -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];
Quoted 8 lines

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

Quoted 9 lines

--D

Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +0 -0
  	error = xfs_attr_node_hasname(args, state);
  	if (error != -EEXIST)
Signature · 1 line
2.7.4
#5 lore raw

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

Quoted 38 lines · Allison Collins
Quoted 27 lines · Darrick J. Wong
Quoted 15 lines · Allison Collins

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.

---
  fs/xfs/libxfs/xfs_attr.c | 2 ++
  1 file changed, 2 insertions(+)
fs/xfs/libxfs/xfs_attr.c +0 -0
index d4583a0..5168d32 100644

fs/xfs/libxfs/xfs_attr.c int xfs_attr_node_removename_setup( · line 1179

Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +2 -0
@@ -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];
Quoted 8 lines

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.

Quoted 7 lines

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

I thought xfs_attr_node_hasname could allocate the da state and set *state, which means that we can't dereference *state until after that call?

--D

Quoted 8 lines
Quoted 8 lines

--D

Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +0 -0
  	error = xfs_attr_node_hasname(args, state);
  	if (error != -EEXIST)
Signature · 1 line
2.7.4
#6 lore raw

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

Quoted 42 lines · Darrick J. Wong
Quoted 41 lines · Allison Collins
Quoted 27 lines · Darrick J. Wong
Quoted 15 lines · Allison Collins

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.

---
   fs/xfs/libxfs/xfs_attr.c | 2 ++
   1 file changed, 2 insertions(+)
fs/xfs/libxfs/xfs_attr.c +0 -0
index d4583a0..5168d32 100644

fs/xfs/libxfs/xfs_attr.c int xfs_attr_node_removename_setup( · line 1179

Quoted 6 lines
fs/xfs/libxfs/xfs_attr.c +2 -0
@@ -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];
Quoted 8 lines

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:

Quoted 8 lines
Quoted 4 lines
#ifdef DEBUG
	struct xfs_da_state_blk	*blk = &(*state)->path.blk[(*state)->path.active -

1];
#endif

I thought xfs_attr_node_hasname could allocate the da state and set *state, which means that we can't dereference *state until after that call?

I see, ok then, will add the deference in the asserts

Allison

Quoted 11 lines

--D

Quoted 8 lines
Quoted 8 lines

--D

Quoted 5 lines
fs/xfs/libxfs/xfs_attr.c +0 -0
   	error = xfs_attr_node_hasname(args, state);
   	if (error != -EEXIST)
Signature · 1 line
2.7.4
#7 lore raw

PATCH v2 2/2 xfs: Fix compiler warning in xfs_attr_shortform_add

In reply to Allison Collins

Fix compiler warning warning: variable 'error' set but not used in xfs_attr_shortform_add. error is used only in an ASSERT so only declare error when DEBUG is set.

---
 fs/xfs/libxfs/xfs_attr_leaf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_attr_leaf.c +4 -1
index ad7b351..db985b8 100644
@@ -715,7 +715,10 @@ xfs_attr_shortform_add(
 {
 	struct xfs_attr_shortform	*sf;
 	struct xfs_attr_sf_entry	*sfe;
-	int				offset, size, error;
+	int				offset, size;
+#if DEBUG
+	int				error;
+#endif
 	struct xfs_mount		*mp;
 	struct xfs_inode		*dp;
 	struct xfs_ifork		*ifp;
Signature · 1 line
2.7.4