diff mbox series

[5/5] xfs: fix sparse warnings about unused interval tree functions

Message ID 20240402213541.1199959-6-david@fromorbit.com (mailing list archive)
State New
Headers show
Series xfs: sparse warning fixes | expand

Commit Message

Dave Chinner April 2, 2024, 9:28 p.m. UTC
From: Dave Chinner <dchinner@redhat.com>

Sparse throws warnings about the interval tree functions that are
defined and then not used in the scrub bitmap code:

fs/xfs/scrub/bitmap.c:57:1: warning: unused function 'xbitmap64_tree_iter_next' [-Wunused-function]
INTERVAL_TREE_DEFINE(struct xbitmap64_node, bn_rbnode, uint64_t,
^
./include/linux/interval_tree_generic.h:151:33: note: expanded from macro 'INTERVAL_TREE_DEFINE'
ITSTATIC ITSTRUCT *                                                           \
                                                                              ^
<scratch space>:3:1: note: expanded from here
xbitmap64_tree_iter_next
^
fs/xfs/scrub/bitmap.c:331:1: warning: unused function 'xbitmap32_tree_iter_next' [-Wunused-function]
INTERVAL_TREE_DEFINE(struct xbitmap32_node, bn_rbnode, uint32_t,
^
./include/linux/interval_tree_generic.h:151:33: note: expanded from macro 'INTERVAL_TREE_DEFINE'
ITSTATIC ITSTRUCT *                                                           \
                                                                              ^
<scratch space>:59:1: note: expanded from here
xbitmap32_tree_iter_next

Fix these by marking the functions created by the interval tree
creation macro as __maybe_unused to suppress this warning.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/scrub/bitmap.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

Comments

Darrick J. Wong April 3, 2024, 3:53 a.m. UTC | #1
On Wed, Apr 03, 2024 at 08:28:32AM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Sparse throws warnings about the interval tree functions that are
> defined and then not used in the scrub bitmap code:
> 
> fs/xfs/scrub/bitmap.c:57:1: warning: unused function 'xbitmap64_tree_iter_next' [-Wunused-function]
> INTERVAL_TREE_DEFINE(struct xbitmap64_node, bn_rbnode, uint64_t,
> ^
> ./include/linux/interval_tree_generic.h:151:33: note: expanded from macro 'INTERVAL_TREE_DEFINE'
> ITSTATIC ITSTRUCT *                                                           \
>                                                                               ^
> <scratch space>:3:1: note: expanded from here
> xbitmap64_tree_iter_next
> ^
> fs/xfs/scrub/bitmap.c:331:1: warning: unused function 'xbitmap32_tree_iter_next' [-Wunused-function]
> INTERVAL_TREE_DEFINE(struct xbitmap32_node, bn_rbnode, uint32_t,
> ^
> ./include/linux/interval_tree_generic.h:151:33: note: expanded from macro 'INTERVAL_TREE_DEFINE'
> ITSTATIC ITSTRUCT *                                                           \
>                                                                               ^
> <scratch space>:59:1: note: expanded from here
> xbitmap32_tree_iter_next
> 
> Fix these by marking the functions created by the interval tree
> creation macro as __maybe_unused to suppress this warning.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Much better than the hatchet job sent in by the last person...
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/scrub/bitmap.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/xfs/scrub/bitmap.c b/fs/xfs/scrub/bitmap.c
> index 0cb8d43912a8..7ba35a7a7920 100644
> --- a/fs/xfs/scrub/bitmap.c
> +++ b/fs/xfs/scrub/bitmap.c
> @@ -40,22 +40,23 @@ struct xbitmap64_node {
>   * These functions are defined by the INTERVAL_TREE_DEFINE macro, but we'll
>   * forward-declare them anyway for clarity.
>   */
> -static inline void
> +static inline __maybe_unused void
>  xbitmap64_tree_insert(struct xbitmap64_node *node, struct rb_root_cached *root);
>  
> -static inline void
> +static inline __maybe_unused void
>  xbitmap64_tree_remove(struct xbitmap64_node *node, struct rb_root_cached *root);
>  
> -static inline struct xbitmap64_node *
> +static inline __maybe_unused struct xbitmap64_node *
>  xbitmap64_tree_iter_first(struct rb_root_cached *root, uint64_t start,
>  			uint64_t last);
>  
> -static inline struct xbitmap64_node *
> +static inline __maybe_unused struct xbitmap64_node *
>  xbitmap64_tree_iter_next(struct xbitmap64_node *node, uint64_t start,
>  		       uint64_t last);
>  
>  INTERVAL_TREE_DEFINE(struct xbitmap64_node, bn_rbnode, uint64_t,
> -		__bn_subtree_last, START, LAST, static inline, xbitmap64_tree)
> +		__bn_subtree_last, START, LAST, static inline __maybe_unused,
> +		xbitmap64_tree)
>  
>  /* Iterate each interval of a bitmap.  Do not change the bitmap. */
>  #define for_each_xbitmap64_extent(bn, bitmap) \
> @@ -314,22 +315,23 @@ struct xbitmap32_node {
>   * These functions are defined by the INTERVAL_TREE_DEFINE macro, but we'll
>   * forward-declare them anyway for clarity.
>   */
> -static inline void
> +static inline __maybe_unused void
>  xbitmap32_tree_insert(struct xbitmap32_node *node, struct rb_root_cached *root);
>  
> -static inline void
> +static inline __maybe_unused void
>  xbitmap32_tree_remove(struct xbitmap32_node *node, struct rb_root_cached *root);
>  
> -static inline struct xbitmap32_node *
> +static inline __maybe_unused struct xbitmap32_node *
>  xbitmap32_tree_iter_first(struct rb_root_cached *root, uint32_t start,
>  			  uint32_t last);
>  
> -static inline struct xbitmap32_node *
> +static inline __maybe_unused struct xbitmap32_node *
>  xbitmap32_tree_iter_next(struct xbitmap32_node *node, uint32_t start,
>  			 uint32_t last);
>  
>  INTERVAL_TREE_DEFINE(struct xbitmap32_node, bn_rbnode, uint32_t,
> -		__bn_subtree_last, START, LAST, static inline, xbitmap32_tree)
> +		__bn_subtree_last, START, LAST, static inline __maybe_unused,
> +		xbitmap32_tree)
>  
>  /* Iterate each interval of a bitmap.  Do not change the bitmap. */
>  #define for_each_xbitmap32_extent(bn, bitmap) \
> -- 
> 2.43.0
> 
>
Christoph Hellwig April 3, 2024, 4:39 a.m. UTC | #2
On Wed, Apr 03, 2024 at 08:28:32AM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Sparse throws warnings about the interval tree functions that are
> defined and then not used in the scrub bitmap code:

Hmm, what sparse version and kernel config is this?  I don't see
warnings in my builds, and I also can't see where they'd come from.
diff mbox series

Patch

diff --git a/fs/xfs/scrub/bitmap.c b/fs/xfs/scrub/bitmap.c
index 0cb8d43912a8..7ba35a7a7920 100644
--- a/fs/xfs/scrub/bitmap.c
+++ b/fs/xfs/scrub/bitmap.c
@@ -40,22 +40,23 @@  struct xbitmap64_node {
  * These functions are defined by the INTERVAL_TREE_DEFINE macro, but we'll
  * forward-declare them anyway for clarity.
  */
-static inline void
+static inline __maybe_unused void
 xbitmap64_tree_insert(struct xbitmap64_node *node, struct rb_root_cached *root);
 
-static inline void
+static inline __maybe_unused void
 xbitmap64_tree_remove(struct xbitmap64_node *node, struct rb_root_cached *root);
 
-static inline struct xbitmap64_node *
+static inline __maybe_unused struct xbitmap64_node *
 xbitmap64_tree_iter_first(struct rb_root_cached *root, uint64_t start,
 			uint64_t last);
 
-static inline struct xbitmap64_node *
+static inline __maybe_unused struct xbitmap64_node *
 xbitmap64_tree_iter_next(struct xbitmap64_node *node, uint64_t start,
 		       uint64_t last);
 
 INTERVAL_TREE_DEFINE(struct xbitmap64_node, bn_rbnode, uint64_t,
-		__bn_subtree_last, START, LAST, static inline, xbitmap64_tree)
+		__bn_subtree_last, START, LAST, static inline __maybe_unused,
+		xbitmap64_tree)
 
 /* Iterate each interval of a bitmap.  Do not change the bitmap. */
 #define for_each_xbitmap64_extent(bn, bitmap) \
@@ -314,22 +315,23 @@  struct xbitmap32_node {
  * These functions are defined by the INTERVAL_TREE_DEFINE macro, but we'll
  * forward-declare them anyway for clarity.
  */
-static inline void
+static inline __maybe_unused void
 xbitmap32_tree_insert(struct xbitmap32_node *node, struct rb_root_cached *root);
 
-static inline void
+static inline __maybe_unused void
 xbitmap32_tree_remove(struct xbitmap32_node *node, struct rb_root_cached *root);
 
-static inline struct xbitmap32_node *
+static inline __maybe_unused struct xbitmap32_node *
 xbitmap32_tree_iter_first(struct rb_root_cached *root, uint32_t start,
 			  uint32_t last);
 
-static inline struct xbitmap32_node *
+static inline __maybe_unused struct xbitmap32_node *
 xbitmap32_tree_iter_next(struct xbitmap32_node *node, uint32_t start,
 			 uint32_t last);
 
 INTERVAL_TREE_DEFINE(struct xbitmap32_node, bn_rbnode, uint32_t,
-		__bn_subtree_last, START, LAST, static inline, xbitmap32_tree)
+		__bn_subtree_last, START, LAST, static inline __maybe_unused,
+		xbitmap32_tree)
 
 /* Iterate each interval of a bitmap.  Do not change the bitmap. */
 #define for_each_xbitmap32_extent(bn, bitmap) \