Messages in this thread | | | Date | Sun, 10 Jun 2007 10:13:14 -0700 | From | Randy Dunlap <> | Subject | Re: [PATCH RFC] struct list_node |
| |
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 *** - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |