Skip to content

Commit 4e4a7fb

Browse files
geliangtangtorvalds
authored andcommitted
proc: use rb_entry()
To make the code clearer, use rb_entry() instead of container_of() to deal with rbtree. Link: http://lkml.kernel.org/r/4fd1f82818665705ce75c5156a060ae7caa8e0a9.1482160150.git.geliangtang@gmail.com Signed-off-by: Geliang Tang <geliangtang@gmail.com> Cc: Jan Kara <jack@suse.cz> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: "David S. Miller" <davem@davemloft.net> Cc: Juergen Gross <jgross@suse.com> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Seth Forshee <seth.forshee@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 35ca695 commit 4e4a7fb

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎fs/proc/generic.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ static struct proc_dir_entry *pde_subdir_find(struct proc_dir_entry *dir,
5757
struct rb_node *node = dir->subdir.rb_node;
5858

5959
while (node) {
60-
struct proc_dir_entry *de = container_of(node,
61-
struct proc_dir_entry,
62-
subdir_node);
60+
struct proc_dir_entry *de = rb_entry(node,
61+
struct proc_dir_entry,
62+
subdir_node);
6363
int result = proc_match(len, name, de);
6464

6565
if (result < 0)
@@ -80,8 +80,9 @@ static bool pde_subdir_insert(struct proc_dir_entry *dir,
8080

8181
/* Figure out where to put new node */
8282
while (*new) {
83-
struct proc_dir_entry *this =
84-
container_of(*new, struct proc_dir_entry, subdir_node);
83+
struct proc_dir_entry *this = rb_entry(*new,
84+
struct proc_dir_entry,
85+
subdir_node);
8586
int result = proc_match(de->namelen, de->name, this);
8687

8788
parent = *new;

0 commit comments

Comments
 (0)