xfs: Fix compiler warnings
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
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
@@ -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
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.Reported-by kernel test robot <[email protected]>Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 2 ++ 1 file changed, 2 insertions(+)fs/xfs/libxfs/xfs_attr.c +0
-0
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
-0error =xfs_attr_node_hasname (args, state);if (error != -EEXIST )Signature · 1 line
2.7.4
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.Reported-by kernel test robot <[email protected]>Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 2 ++ 1 file changed, 2 insertions(+)fs/xfs/libxfs/xfs_attr.c +0
-0fs/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
-0error =xfs_attr_node_hasname (args, state);if (error != -EEXIST )Signature · 1 line
2.7.4
Re: [PATCH v2 1/2] xfs: Fix compiler warning in xfs_attr_node_removename_setup
In reply to Darrick J. WongQuoted 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.Reported-by kernel test robot <[email protected]>Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 2 ++ 1 file changed, 2 insertions(+)fs/xfs/libxfs/xfs_attr.c +0
-0fs/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
-0error =xfs_attr_node_hasname (args, state);if (error != -EEXIST )Signature · 1 line
2.7.4
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.Reported-by kernel test robot <[email protected]>Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 2 ++ 1 file changed, 2 insertions(+)fs/xfs/libxfs/xfs_attr.c +0
-0fs/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
-0error =xfs_attr_node_hasname (args, state);if (error != -EEXIST )Signature · 1 line
2.7.4
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.Reported-by kernel test robot <[email protected]>Signed-off-by Allison Collins <[email protected]>--- fs/xfs/libxfs/xfs_attr.c | 2 ++ 1 file changed, 2 insertions(+)fs/xfs/libxfs/xfs_attr.c +0
-0fs/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];
#endifI thought
xfs_attr_node_hasnamecould 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
-0error =xfs_attr_node_hasname (args, state);if (error != -EEXIST )Signature · 1 line
2.7.4
PATCH v2 2/2 xfs: Fix compiler warning in xfs_attr_shortform_add
In reply to Allison CollinsFix 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
@@ -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