Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Arnd Bergmann and committed by
Andrew Morton
bde1597d 2f012f2b

+15 -6
+2
lib/radix-tree.c
··· 27 27 #include <linux/string.h> 28 28 #include <linux/xarray.h> 29 29 30 + #include "radix-tree.h" 31 + 30 32 /* 31 33 * Radix tree node cache. 32 34 */
+8
lib/radix-tree.h
··· 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);
+2 -4
lib/xarray.c
··· 12 12 #include <linux/slab.h> 13 13 #include <linux/xarray.h> 14 14 15 + #include "radix-tree.h" 16 + 15 17 /* 16 18 * Coding conventions in this file: 17 19 * ··· 248 246 return entry; 249 247 } 250 248 EXPORT_SYMBOL_GPL(xas_load); 251 - 252 - /* Move the radix tree node cache here */ 253 - extern struct kmem_cache *radix_tree_node_cachep; 254 - extern void radix_tree_node_rcu_free(struct rcu_head *head); 255 249 256 250 #define XA_RCU_FREE ((struct xarray *)1) 257 251
+3 -2
tools/testing/radix-tree/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 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 5 5 LDFLAGS += -fsanitize=address -fsanitize=undefined 6 6 LDLIBS+= -lpthread -lurcu 7 7 TARGETS = main idr-test multiorder xarray maple ··· 49 49 ../../../include/linux/xarray.h \ 50 50 ../../../include/linux/maple_tree.h \ 51 51 ../../../include/linux/radix-tree.h \ 52 + ../../../lib/radix-tree.h \ 52 53 ../../../include/linux/idr.h 53 54 54 55 radix-tree.c: ../../../lib/radix-tree.c