proc: use rb_entry()
authorGeliang Tang <geliangtang@gmail.com>
Fri, 24 Feb 2017 23:00:17 +0000 (15:00 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 25 Feb 2017 01:46:56 +0000 (17:46 -0800)
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>
fs/proc/generic.c

index f6a01f09f79d51457dae4226c9882bf60076c588..06c73904d497ad644fae969774fa8f8477486b4f 100644 (file)
@@ -57,9 +57,9 @@ static struct proc_dir_entry *pde_subdir_find(struct proc_dir_entry *dir,
        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 proc_dir_entry *dir,
 
        /* 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;