Skip to contentSkip to conversation

proc: use rb_entry()

PATCH New [email protected] 1 participant 1 message Feb 24, 2017 Proc filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 95/124 proc: use rb_entry()

From: Geliang Tang <[email protected]>
Subject: proc: use rb_entry()

To make the code clearer, use rb_entry() instead of container_of() to deal with rbtree.

---

 fs/proc/generic.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
fs/proc/generic.c renamed from fs/proc/generic.c~proc-use-rb_entry +6 -5
diff -puN fs/proc/generic.c~proc-use-rb_entry fs/proc/generic.c
@@ -57,9 +57,9 @@ static struct proc_dir_entry *pde_subdir
 	struct rb_node *node = dir->subdir.rb_node;
 
 	while (node) {
-		struct proc_dir_entry *de = container_of(node,
-							 struct proc_dir_entry,
-							 subdir_node);
+		struct proc_dir_entry *de = rb_entry(node,
+						     struct proc_dir_entry,
+						     subdir_node);
 		int result = proc_match(len, name, de);
 
 		if (result < 0)
@@ -80,8 +80,9 @@ static bool pde_subdir_insert(struct pro
 
 	/* Figure out where to put new node */
 	while (*new) {
-		struct proc_dir_entry *this =
-			container_of(*new, struct proc_dir_entry, subdir_node);
+		struct proc_dir_entry *this = rb_entry(*new,
+						       struct proc_dir_entry,
+						       subdir_node);
 		int result = proc_match(de->namelen, de->name, this);
 
 		parent = *new;

_