diff mbox series

test_ida: Fix compilation errors

Message ID 20231112070840.327190-1-shiqiang.deng213@gmail.com (mailing list archive)
State New
Headers show
Series test_ida: Fix compilation errors | expand

Commit Message

shiqiang.deng Nov. 12, 2023, 7:08 a.m. UTC
In lib/test_ida.c, we found that IDA_BUG_ON
uses the ida_dump() function. When __ Kernel__ is not defined,
a missing-prototypes error will occur during compilation.
Fix it now.

Signed-off-by: shiqiang.deng <shiqiang.deng213@gmail.com>
---
 include/linux/idr.h | 4 ++++
 lib/idr.c           | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Matthew Wilcox Nov. 12, 2023, 3:31 p.m. UTC | #1
On Sun, Nov 12, 2023 at 03:08:40PM +0800, shiqiang.deng wrote:
> In lib/test_ida.c, we found that IDA_BUG_ON
> uses the ida_dump() function. When __ Kernel__ is not defined,
> a missing-prototypes error will occur during compilation.
> Fix it now.

I'm confused.  What were you doing to get this error?

> Signed-off-by: shiqiang.deng <shiqiang.deng213@gmail.com>
> ---
>  include/linux/idr.h | 4 ++++
>  lib/idr.c           | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/idr.h b/include/linux/idr.h
> index a0dce14090a9..e091efdc0cf7 100644
> --- a/include/linux/idr.h
> +++ b/include/linux/idr.h
> @@ -109,6 +109,10 @@ static inline void idr_set_cursor(struct idr *idr, unsigned int val)
>  #define idr_unlock_irqrestore(idr, flags) \
>  				xa_unlock_irqrestore(&(idr)->idr_rt, flags)
>  
> +#ifndef __KERNEL__
> +void ida_dump(struct ida *ida);
> +#endif
> +
>  void idr_preload(gfp_t gfp_mask);
>  
>  int idr_alloc(struct idr *, void *ptr, int start, int end, gfp_t);
> diff --git a/lib/idr.c b/lib/idr.c
> index 13f2758c2377..66d0c6e30588 100644
> --- a/lib/idr.c
> +++ b/lib/idr.c
> @@ -589,7 +589,7 @@ static void ida_dump_entry(void *entry, unsigned long index)
>  	}
>  }
>  
> -static void ida_dump(struct ida *ida)
> +void ida_dump(struct ida *ida)
>  {
>  	struct xarray *xa = &ida->xa;
>  	pr_debug("ida: %p node %p free %d\n", ida, xa->xa_head,
> -- 
> 2.30.0
>
diff mbox series

Patch

diff --git a/include/linux/idr.h b/include/linux/idr.h
index a0dce14090a9..e091efdc0cf7 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -109,6 +109,10 @@  static inline void idr_set_cursor(struct idr *idr, unsigned int val)
 #define idr_unlock_irqrestore(idr, flags) \
 				xa_unlock_irqrestore(&(idr)->idr_rt, flags)
 
+#ifndef __KERNEL__
+void ida_dump(struct ida *ida);
+#endif
+
 void idr_preload(gfp_t gfp_mask);
 
 int idr_alloc(struct idr *, void *ptr, int start, int end, gfp_t);
diff --git a/lib/idr.c b/lib/idr.c
index 13f2758c2377..66d0c6e30588 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -589,7 +589,7 @@  static void ida_dump_entry(void *entry, unsigned long index)
 	}
 }
 
-static void ida_dump(struct ida *ida)
+void ida_dump(struct ida *ida)
 {
 	struct xarray *xa = &ida->xa;
 	pr_debug("ida: %p node %p free %d\n", ida, xa->xa_head,