Skip to content

Commit bde1597

Browse files
arndbakpm00
authored andcommitted
radix-tree: move declarations to header
The xarray.c file contains the only call to radix_tree_node_rcu_free(), and it comes with its own extern declaration for it. This means the function definition causes a missing-prototype warning: lib/radix-tree.c:288:6: error: no previous prototype for 'radix_tree_node_rcu_free' [-Werror=missing-prototypes] Instead, move the declaration for this function to a new header that can be included by both, and do the same for the radix_tree_node_cachep variable that has the same underlying problem but does not cause a warning with gcc. [zhangpeng.00@bytedance.com: fix building radix tree test suite] Link: https://lkml.kernel.org/r/20230521095450.21332-1-zhangpeng.00@bytedance.com Link: https://lkml.kernel.org/r/20230516194212.548910-1-arnd@kernel.org Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 2f012f2 commit bde1597

4 files changed

Lines changed: 15 additions & 6 deletions

File tree

lib/radix-tree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <linux/string.h>
2828
#include <linux/xarray.h>
2929

30+
#include "radix-tree.h"
31+
3032
/*
3133
* Radix tree node cache.
3234
*/

lib/radix-tree.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: GPL-2.0+
2+
/* radix-tree helpers that are only shared with xarray */
3+
4+
struct kmem_cache;
5+
struct rcu_head;
6+
7+
extern struct kmem_cache *radix_tree_node_cachep;
8+
extern void radix_tree_node_rcu_free(struct rcu_head *head);

lib/xarray.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <linux/slab.h>
1313
#include <linux/xarray.h>
1414

15+
#include "radix-tree.h"
16+
1517
/*
1618
* Coding conventions in this file:
1719
*
@@ -247,10 +249,6 @@ void *xas_load(struct xa_state *xas)
247249
}
248250
EXPORT_SYMBOL_GPL(xas_load);
249251

250-
/* Move the radix tree node cache here */
251-
extern struct kmem_cache *radix_tree_node_cachep;
252-
extern void radix_tree_node_rcu_free(struct rcu_head *head);
253-
254252
#define XA_RCU_FREE ((struct xarray *)1)
255253

256254
static void xa_node_free(struct xa_node *node)

tools/testing/radix-tree/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22

3-
CFLAGS += -I. -I../../include -g -Og -Wall -D_LGPL_SOURCE -fsanitize=address \
4-
-fsanitize=undefined
3+
CFLAGS += -I. -I../../include -I../../../lib -g -Og -Wall \
4+
-D_LGPL_SOURCE -fsanitize=address -fsanitize=undefined
55
LDFLAGS += -fsanitize=address -fsanitize=undefined
66
LDLIBS+= -lpthread -lurcu
77
TARGETS = main idr-test multiorder xarray maple
@@ -49,6 +49,7 @@ $(OFILES): Makefile *.h */*.h generated/map-shift.h generated/bit-length.h \
4949
../../../include/linux/xarray.h \
5050
../../../include/linux/maple_tree.h \
5151
../../../include/linux/radix-tree.h \
52+
../../../lib/radix-tree.h \
5253
../../../include/linux/idr.h
5354

5455
radix-tree.c: ../../../lib/radix-tree.c

0 commit comments

Comments
 (0)