Skip to contentSkip to conversation

test_ida: Fix compilation errors

PATCH In review shiqiang.deng 2 participants 2 messages Nov 12, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test_ida: Fix compilation errors

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.

---
 include/linux/idr.h | 4 ++++
 lib/idr.c           | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
include/linux/idr.h +4 -0
index a0dce14090a9..e091efdc0cf7 100644
@@ -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);
lib/idr.c +1 -1
index 13f2758c2377..66d0c6e30588 100644
@@ -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,
Signature · 1 line
2.30.0
maintainer
#1 lore raw
Quoted 4 lines · shiqiang.deng

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?

Quoted 37 lines
---
 include/linux/idr.h | 4 ++++
 lib/idr.c           | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
include/linux/idr.h +4 -0
index a0dce14090a9..e091efdc0cf7 100644
@@ -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);
lib/idr.c +1 -1
index 13f2758c2377..66d0c6e30588 100644
@@ -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,
Signature · 1 line
2.30.0