From: Ian Abbott <abbotti@mev.co.uk>
To: Rob Landley <rob@landley.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Corrections to Documentation/rbtree.txt
Date: Tue, 25 Mar 2008 11:29:43 +0000 [thread overview]
Message-ID: <47E8E227.7040105@mev.co.uk> (raw)
In-Reply-To: <200803201339.18618.rob@landley.net>
On 20/03/08 18:39, Rob Landley wrote:
> On Thursday 20 March 2008 10:29:57 Ian Abbott wrote:
>> From: Ian Abbott <abbotti@mev.co.uk>
>>
>> The description of the rb_entry() macro in Documentation/rbtree.txt seems
>> incorrect. This patch improves it (hopefully). Also I changed the example
>> code to call the previous 'my_search()' example instead of an undefined
>> 'mysearch()'.
>
> I have no objection to the patch (and the my_search thing seems like an
> obvious typo), but is there a reason to prefer rb_entry() rather than
> container_of()? If so, the rationale might be a good thing to add to the
> documentation...
I forgot to mention this in my earlier post, but while we're on the
subject, it might be worth renaming the 'node' variable in the
'my_search()' and iteration examples to avoid confusion in the use of
the rb_entry() (or container_of() macro), for example in 'my_search()',
instead of:
struct rb_node *node = root->rb_node;
while (node) {
struct mytype *data = rb_entry(node, struct mytype, node);
I think this is clearer:
struct rb_node *pn = root->rb_node;
while (pn) {
struct mytype *data = rb_entry(pn, struct mytype, node);
(I used rb_entry instead of container_of in the above. Also, there are
probably better, longer variable names than 'pn', e.g. 'rbn' or 'rbnode'
or 'pnode'.)
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
prev parent reply other threads:[~2008-03-25 11:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-20 15:29 [PATCH] Corrections to Documentation/rbtree.txt Ian Abbott
2008-03-20 18:39 ` Rob Landley
2008-03-25 11:02 ` Ian Abbott
2008-03-25 18:24 ` Rob Landley
2008-03-26 14:09 ` Ian Abbott
2008-03-25 11:29 ` Ian Abbott [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47E8E227.7040105@mev.co.uk \
--to=abbotti@mev.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=rob@landley.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox