xfs: fix unused variable warning in xfs_buf_item_unlock()
PATCH 1/1 xfs: fix unused variable warning in xfs_buf_item_unlock()
The ordered variable generates an unused warning on !DEBUG builds. Separate the initialization of the associated variables from the declarations to quiet gcc.
--- fs/xfs/xfs_buf_item.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
fs/xfs/xfs_buf_item.c +9 -4
@@ -567,10 +567,15 @@ xfs_buf_item_unlock( {struct xfs_buf_log_item *bip =BUF_ITEM (lip);struct xfs_buf *bp = bip->bli_buf; -bool aborted = !!(lip->li_flags &XFS_LI_ABORTED ); -bool hold = !!(bip->bli_flags &XFS_BLI_HOLD ); -bool dirty = !!(bip->bli_flags &XFS_BLI_DIRTY ); -bool ordered = !!(bip->bli_flags &XFS_BLI_ORDERED ); +bool aborted; +bool hold; +bool dirty; +bool ordered; + + aborted = !!(lip->li_flags &XFS_LI_ABORTED ); + hold = !!(bip->bli_flags &XFS_BLI_HOLD ); + dirty = !!(bip->bli_flags &XFS_BLI_DIRTY ); + ordered = !!(bip->bli_flags &XFS_BLI_ORDERED );/* Clear the buffer's association with this transaction. */ bp->b_transp =NULL ;
Signature · 1 line
2.9.5
Quoted 5 lines · Brian Foster
The ordered variable generates an unused warning on !DEBUG builds. Separate the initialization of the associated variables from the declarations to quiet gcc.
Signed-off-by Brian Foster <[email protected]>
Quoted 35 lines
--- fs/xfs/xfs_buf_item.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)fs/xfs/xfs_buf_item.c +9
-4@@ -567,10 +567,15 @@ xfs_buf_item_unlock( {struct xfs_buf_log_item *bip =BUF_ITEM (lip);struct xfs_buf *bp = bip->bli_buf; -bool aborted = !!(lip->li_flags &XFS_LI_ABORTED ); -bool hold = !!(bip->bli_flags &XFS_BLI_HOLD ); -bool dirty = !!(bip->bli_flags &XFS_BLI_DIRTY ); -bool ordered = !!(bip->bli_flags &XFS_BLI_ORDERED ); +bool aborted; +bool hold; +bool dirty; +bool ordered; + + aborted = !!(lip->li_flags &XFS_LI_ABORTED ); + hold = !!(bip->bli_flags &XFS_BLI_HOLD ); + dirty = !!(bip->bli_flags &XFS_BLI_DIRTY ); + ordered = !!(bip->bli_flags &XFS_BLI_ORDERED );/* Clear the buffer's association with this transaction. */ bp->b_transp =NULL ;Signature · 6 lines
2.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Darrick J. Wong
Quoted 5 lines · Brian Foster
The ordered variable generates an unused warning on !DEBUG builds. Separate the initialization of the associated variables from the declarations to quiet gcc.
Signed-off-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>
And merged before everyone in different timezones has had a chance to comment. :(
I just built the latest for-next with CONFIG_XFS_DEBUG=n and there's three set-but-unused warnings, one of which is introduced by this patch.
fs/xfs/libxfs/xfs_inode_fork.c: In function ¿xfs_iext_realloc_indirect¿:fs/xfs/libxfs/xfs_inode_fork.c:1503:7: error: variable ¿size¿ set but not used [-Werror=unused-but-set-variable]
int size; /* current indirection array size */
^~~~
fs/xfs/xfs_buf_item.c: In function ¿xfs_buf_item_unlock¿:fs/xfs/xfs_buf_item.c:573:9: error: variable ¿ordered¿ set but not used [-Werror=unused-but-set-variable]
bool ordered;
^~~~~~~fs/xfs/xfs_log_recover.c: In function ¿xlog_recover_process_intents¿:fs/xfs/xfs_log_recover.c:4830:13: error: variable ¿last_lsn¿ set but not used [-Werror=unused-but-set-variable]
xfs_lsn_t last_lsn;
^~~~~~~~Yeah, maintainer habits die hard; I'm still patching fs/xfs/Makefile in my build trees with this:
-ccflags-y += -I$(src) # needed for trace events
+ccflags-y += -I$(src) -Werror -Wunused-but-set-variable
Which catches stupid problems like this that will the userspace libxfs build will trip over when the next merge occurs.
Playing games with declaration/initialisation order to avoid warnigns just doesn't work.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 38 lines · Dave Chinner
Quoted 8 lines · Darrick J. Wong
Quoted 5 lines · Brian Foster
The ordered variable generates an unused warning on !DEBUG builds. Separate the initialization of the associated variables from the declarations to quiet gcc.
Signed-off-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>And merged before everyone in different timezones has had a chance to comment. :(
I just built the latest for-next with
CONFIG_XFS_DEBUG=nand there's three set-but-unused warnings, one of which is introduced by this patch.
fs/xfs/libxfs/xfs_inode_fork.c: In function ¿xfs_iext_realloc_indirect¿:fs/xfs/libxfs/xfs_inode_fork.c:1503:7: error: variable ¿size¿ set but not used [-Werror=unused-but-set-variable]
int size; /* current indirection array size */^~~~
fs/xfs/xfs_buf_item.c: In function ¿xfs_buf_item_unlock¿:fs/xfs/xfs_buf_item.c:573:9: error: variable ¿ordered¿ set but not used [-Werror=unused-but-set-variable]bool ordered; ^~~~~~~
fs/xfs/xfs_log_recover.c: In function ¿xlog_recover_process_intents¿:fs/xfs/xfs_log_recover.c:4830:13: error: variable ¿last_lsn¿ set but not used [-Werror=unused-but-set-variable]xfs_lsn_t last_lsn; ^~~~~~~~Yeah, maintainer habits die hard; I'm still patching
fs/xfs/Makefilein my build trees with this:(quoted diff) +1
-1-ccflags-y += -I$(src) # needed for trace events +ccflags-y += -I$(src) -Werror -Wunused-but-set-variable
Quoted 3 lines
Which catches stupid problems like this that will the userspace libxfs build will trip over when the next merge occurs.
Note that the associated bli code is not shared with userspace, fwiw. We should probably fix the warnings regardless...
Hmm, I don't see that option enabled in xfsprogs. Is the issue then that it is more of a default behavior and the kernel disables it somewhere? After poking around a bit, that appears to be the case. We can run 'make W=1' to generate these (and more) in the kernel build.
Brian
Quoted 13 lines
Playing games with declaration/initialisation order to avoid warnigns just doesn't work.
Cheers,
Dave.
Signature · 6 lines
Dave Chinner [email protected] -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 46 lines · Brian Foster
Quoted 38 lines · Dave Chinner
Quoted 8 lines · Darrick J. Wong
Quoted 5 lines · Brian Foster
The ordered variable generates an unused warning on !DEBUG builds. Separate the initialization of the associated variables from the declarations to quiet gcc.
Signed-off-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>And merged before everyone in different timezones has had a chance to comment. :(
I just built the latest for-next with
CONFIG_XFS_DEBUG=nand there's three set-but-unused warnings, one of which is introduced by this patch.
fs/xfs/libxfs/xfs_inode_fork.c: In function ¿xfs_iext_realloc_indirect¿:fs/xfs/libxfs/xfs_inode_fork.c:1503:7: error: variable ¿size¿ set but not used [-Werror=unused-but-set-variable]
int size; /* current indirection array size */^~~~
fs/xfs/xfs_buf_item.c: In function ¿xfs_buf_item_unlock¿:fs/xfs/xfs_buf_item.c:573:9: error: variable ¿ordered¿ set but not used [-Werror=unused-but-set-variable]bool ordered; ^~~~~~~
fs/xfs/xfs_log_recover.c: In function ¿xlog_recover_process_intents¿:fs/xfs/xfs_log_recover.c:4830:13: error: variable ¿last_lsn¿ set but not used [-Werror=unused-but-set-variable]xfs_lsn_t last_lsn; ^~~~~~~~Yeah, maintainer habits die hard; I'm still patching
fs/xfs/Makefilein my build trees with this:(quoted diff) +1
-1-ccflags-y += -I$(src) # needed for trace events +ccflags-y += -I$(src) -Werror -Wunused-but-set-variableQuoted 3 lines
Which catches stupid problems like this that will the userspace libxfs build will trip over when the next merge occurs.
Note that the associated bli code is not shared with userspace, fwiw. We should probably fix the warnings regardless...
Quoted 2 lines
Hmm, I don't see that option enabled in xfsprogs. Is the issue then that it is more of a default behavior and the kernel disables it somewhere?
Yup, it's default gcc behaviour since early 5.x, IIRC, and the kernel build disables a bunch of different warnings including this one.
Quoted 2 lines
After poking around a bit, that appears to be the case. We can run 'make W=1' to generate these (and more) in the kernel build.
Oh, yeah, but we don't want to do that by default because the kernel headers throw huge numbers of warnings (e.g. signed v unsigned char) that won't ever get fixed. There's been heat and light expended on LKML over fixing these warnings in the past, but the only outcome of those discussion was to add the "-W1" option to allow people who cared to see all the warnings that don't indicate a problem and so won't get fixed....
Hence I started adding my own flags for XFS builds so I would avoid adding code to the kernel that would throw userspace warnings.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]