public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rob Landley <rob@landley.net>
To: Ian Abbott <abbotti@mev.co.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Corrections to Documentation/rbtree.txt
Date: Tue, 25 Mar 2008 13:24:08 -0500	[thread overview]
Message-ID: <200803251324.08769.rob@landley.net> (raw)
In-Reply-To: <47E8DBBE.4030607@mev.co.uk>

On Tuesday 25 March 2008 06:02:22 Ian Abbott wrote:
> 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 don't know the rationale, but all the code I can see uses rb_entry()
> and not container_of().

Except container_of() works, which is a nice thing to know, and it already 
mentions rb_entry() as another way to do it.  If someone could explain _why_ 
to use one over the other, that would be a good thing to add.

> The only rationale I can think of is that it 
> abstracts away from the nodes being embedded in the data a little bit.

If I wanted abstraction for its own sake I'd be using C++ to implement a 
microkernel.  I would also be certifiably insane.

> (But not by much - in particular, an implementation of rb trees that
> stored data in the node explicitly would only need a single parameter in
> its rb_entry() accessor.  I like the approach taken in
> include/linux/elevator.h that uses the rb_entry() macro to create a
> specialized accessor macro (rb_entry_rq()) with a single parameter.

And this can't be done with container_of()?

Again, I don't care much either way, I just want to know what the point is of 
choosing one over the other that makes changing what's there worth bothering 
with.  You're changing the documentation to hide the fact that rb_entry() is 
basically another name for container_of(), and this is supposed to be an 
improvement?

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.

  reply	other threads:[~2008-03-25 18:24 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 [this message]
2008-03-26 14:09       ` Ian Abbott
2008-03-25 11:29   ` Ian Abbott

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=200803251324.08769.rob@landley.net \
    --to=rob@landley.net \
    --cc=abbotti@mev.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    /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