From: Randy Dunlap <randy.dunlap@oracle.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC] struct list_node
Date: Sun, 10 Jun 2007 10:13:14 -0700 [thread overview]
Message-ID: <20070610101314.cd63dec2.randy.dunlap@oracle.com> (raw)
In-Reply-To: <1181452290.16428.7.camel@localhost.localdomain>
On Sun, 10 Jun 2007 15:11:30 +1000 Rusty Russell wrote:
> The current list.h has the same type for list elements and list heads
> even though most code and coders treat them as distinct.
>
> I've had a version of list.h (for userspace work) for about a year
> which uses a different type for nodes and it works very well: code is
> clearer, and mistakes like list_add() argument reversal are detected.
> Code which really wants to treat a list node as a head can append ".h".
>
> To avoid a massive flag day, this patch uses gcc's "cast to union" to
> allow either list_head or list_node in various places.
>
> Notes:
> 1) A new function in_list() is introduced, equivalent to "list_empty(&e)"
> but for nodes.
in_list() sounds like it would scan an entire list and return true
if &e is found, false if &e is not found...
and that's what the short description sounds like to me as well...
I'm just confuzed. And you aren't supposed to write confuzing
interfaces. :)
> +/**
> + * in_list - tests whether element is in a list.
> + * @entry: the entry to test
> + *
> + * Returns false if the list elem was deleted from list (except __list_del)
What is "elem"? How can this function determine is a list element was
deleted vs. was never added?
> + */
> +static inline int in_list(const struct list_node *entry)
> +{
> + return entry->h.next == &entry->h;
> }
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
next prev parent reply other threads:[~2007-06-10 17:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-10 5:11 Rusty Russell
2007-06-10 17:13 ` Randy Dunlap [this message]
2007-06-10 17:20 ` Linus Torvalds
2007-06-10 20:19 ` Linus Torvalds
2007-06-11 0:08 ` Rusty Russell
2007-06-11 0:02 ` Rusty Russell
2007-06-14 10:03 ` Jan Blunck
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=20070610101314.cd63dec2.randy.dunlap@oracle.com \
--to=randy.dunlap@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®