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

Configure Feed

Select the types of activity you want to include in your feed.

nstree: simplify rbtree comparison helpers

They all do the same basic thing.

Link: https://patch.msgid.link/20251029-work-namespace-nstree-listns-v4-17-2e6f823ebdc0@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

+11 -29
+11 -29
kernel/nstree.c
··· 92 92 return rb_entry(node, struct ns_common, ns_owner_tree_node); 93 93 } 94 94 95 - static inline int ns_cmp(struct rb_node *a, const struct rb_node *b) 95 + static int ns_id_cmp(u64 id_a, u64 id_b) 96 96 { 97 - struct ns_common *ns_a = node_to_ns(a); 98 - struct ns_common *ns_b = node_to_ns(b); 99 - u64 ns_id_a = ns_a->ns_id; 100 - u64 ns_id_b = ns_b->ns_id; 101 - 102 - if (ns_id_a < ns_id_b) 97 + if (id_a < id_b) 103 98 return -1; 104 - if (ns_id_a > ns_id_b) 99 + if (id_a > id_b) 105 100 return 1; 106 101 return 0; 107 102 } 108 103 109 - static inline int ns_cmp_unified(struct rb_node *a, const struct rb_node *b) 104 + static int ns_cmp(struct rb_node *a, const struct rb_node *b) 110 105 { 111 - struct ns_common *ns_a = node_to_ns_unified(a); 112 - struct ns_common *ns_b = node_to_ns_unified(b); 113 - u64 ns_id_a = ns_a->ns_id; 114 - u64 ns_id_b = ns_b->ns_id; 115 - 116 - if (ns_id_a < ns_id_b) 117 - return -1; 118 - if (ns_id_a > ns_id_b) 119 - return 1; 120 - return 0; 106 + return ns_id_cmp(node_to_ns(a)->ns_id, node_to_ns(b)->ns_id); 121 107 } 122 108 123 - static inline int ns_cmp_owner(struct rb_node *a, const struct rb_node *b) 109 + static int ns_cmp_unified(struct rb_node *a, const struct rb_node *b) 124 110 { 125 - struct ns_common *ns_a = node_to_ns_owner(a); 126 - struct ns_common *ns_b = node_to_ns_owner(b); 127 - u64 ns_id_a = ns_a->ns_id; 128 - u64 ns_id_b = ns_b->ns_id; 111 + return ns_id_cmp(node_to_ns_unified(a)->ns_id, node_to_ns_unified(b)->ns_id); 112 + } 129 113 130 - if (ns_id_a < ns_id_b) 131 - return -1; 132 - if (ns_id_a > ns_id_b) 133 - return 1; 134 - return 0; 114 + static int ns_cmp_owner(struct rb_node *a, const struct rb_node *b) 115 + { 116 + return ns_id_cmp(node_to_ns_owner(a)->ns_id, node_to_ns_owner(b)->ns_id); 135 117 } 136 118 137 119 void __ns_tree_add_raw(struct ns_common *ns, struct ns_tree *ns_tree)