* [PATCH 0/3] Documentation/rbtree.txt changes @ 2012-09-04 16:28 Ian Abbott 2012-09-04 16:28 ` [PATCH 1/3] Documentation/rbtree.txt: Fix possible typo in example Ian Abbott ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: Ian Abbott @ 2012-09-04 16:28 UTC (permalink / raw) To: Rob Landley, linux-doc; +Cc: lkml Some rbtree documentation fixes/changes. After applying these changes, the rb_entry() macro only gets a single mention in the document to say it does the same thing as container_of(). 1) Documentation/rbtree.txt: Fix possible typo in example 2) Documentation/rbtree.txt: Remove bogus description of rb_entry() 3) Documentation/rbtree.txt: Mention rb_entry() Documentation/rbtree.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] Documentation/rbtree.txt: Fix possible typo in example 2012-09-04 16:28 [PATCH 0/3] Documentation/rbtree.txt changes Ian Abbott @ 2012-09-04 16:28 ` Ian Abbott 2012-09-04 16:28 ` [PATCH 2/3] Documentation/rbtree.txt: Remove bogus description of rb_entry() Ian Abbott 2012-09-04 16:28 ` [PATCH 3/3] Documentation/rbtree.txt: Mention rb_entry() Ian Abbott 2 siblings, 0 replies; 4+ messages in thread From: Ian Abbott @ 2012-09-04 16:28 UTC (permalink / raw) To: Rob Landley, linux-doc; +Cc: lkml, Ian Abbott The example code for rb_erase() usage has a function call to mysearch(). Presumably this ought to be my_search() to match the example code earlier in the document. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> --- Documentation/rbtree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/rbtree.txt b/Documentation/rbtree.txt index 8d32d85..d4a31e0 100644 --- a/Documentation/rbtree.txt +++ b/Documentation/rbtree.txt @@ -146,7 +146,7 @@ To remove an existing node from a tree, call: Example: - struct mytype *data = mysearch(&mytree, "walrus"); + struct mytype *data = my_search(&mytree, "walrus"); if (data) { rb_erase(&data->node, &mytree); -- 1.7.12 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] Documentation/rbtree.txt: Remove bogus description of rb_entry() 2012-09-04 16:28 [PATCH 0/3] Documentation/rbtree.txt changes Ian Abbott 2012-09-04 16:28 ` [PATCH 1/3] Documentation/rbtree.txt: Fix possible typo in example Ian Abbott @ 2012-09-04 16:28 ` Ian Abbott 2012-09-04 16:28 ` [PATCH 3/3] Documentation/rbtree.txt: Mention rb_entry() Ian Abbott 2 siblings, 0 replies; 4+ messages in thread From: Ian Abbott @ 2012-09-04 16:28 UTC (permalink / raw) To: Rob Landley, linux-doc; +Cc: lkml, Ian Abbott In two places, the document mentions that individual members of the containing structure of the struct rb_node may be accessed by a macro call such as rb_entry(node, type, member). This is bogus, so remove the offending text. The example code used to amplify this bogosity, but that was fixed in a patch by Wang Tinggong back in May/June 2009. However, the example code uses rb_entry() to access the containing structure whereas the preceding paragraph (now) only mentions container_of(), so change the example to match the preceding text. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> --- Documentation/rbtree.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Documentation/rbtree.txt b/Documentation/rbtree.txt index d4a31e0..47a8cb5 100644 --- a/Documentation/rbtree.txt +++ b/Documentation/rbtree.txt @@ -64,8 +64,7 @@ Data nodes in an rbtree tree are structures containing a struct rb_node member: }; When dealing with a pointer to the embedded struct rb_node, the containing data -structure may be accessed with the standard container_of() macro. In addition, -individual members may be accessed directly via rb_entry(node, type, member). +structure may be accessed with the standard container_of() macro. At the root of each rbtree is an rb_root structure, which is initialized to be empty via: @@ -181,14 +180,13 @@ NULL when there are no more nodes left. The iterator functions return a pointer to the embedded struct rb_node, from which the containing data structure may be accessed with the container_of() -macro, and individual members may be accessed directly via -rb_entry(node, type, member). +macro. Example: struct rb_node *node; for (node = rb_first(&mytree); node; node = rb_next(node)) - printk("key=%s\n", rb_entry(node, struct mytype, node)->keystring); + printk("key=%s\n", container_of(node, struct mytype, node)->keystring); Support for Augmented rbtrees ----------------------------- -- 1.7.12 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] Documentation/rbtree.txt: Mention rb_entry() 2012-09-04 16:28 [PATCH 0/3] Documentation/rbtree.txt changes Ian Abbott 2012-09-04 16:28 ` [PATCH 1/3] Documentation/rbtree.txt: Fix possible typo in example Ian Abbott 2012-09-04 16:28 ` [PATCH 2/3] Documentation/rbtree.txt: Remove bogus description of rb_entry() Ian Abbott @ 2012-09-04 16:28 ` Ian Abbott 2 siblings, 0 replies; 4+ messages in thread From: Ian Abbott @ 2012-09-04 16:28 UTC (permalink / raw) To: Rob Landley, linux-doc; +Cc: lkml, Ian Abbott Mention that rb_entry() can be used as a synonym for the standard container_of() macro. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> --- Documentation/rbtree.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/rbtree.txt b/Documentation/rbtree.txt index 47a8cb5..55008c3 100644 --- a/Documentation/rbtree.txt +++ b/Documentation/rbtree.txt @@ -64,7 +64,8 @@ Data nodes in an rbtree tree are structures containing a struct rb_node member: }; When dealing with a pointer to the embedded struct rb_node, the containing data -structure may be accessed with the standard container_of() macro. +structure may be accessed with the standard container_of() macro, or by the +rb_entry() macro which is a synonym for container_of(). At the root of each rbtree is an rb_root structure, which is initialized to be empty via: -- 1.7.12 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-04 16:28 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-09-04 16:28 [PATCH 0/3] Documentation/rbtree.txt changes Ian Abbott 2012-09-04 16:28 ` [PATCH 1/3] Documentation/rbtree.txt: Fix possible typo in example Ian Abbott 2012-09-04 16:28 ` [PATCH 2/3] Documentation/rbtree.txt: Remove bogus description of rb_entry() Ian Abbott 2012-09-04 16:28 ` [PATCH 3/3] Documentation/rbtree.txt: Mention rb_entry() Ian Abbott
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).