From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
ananth@in.ibm.com, jkenisto@us.ibm.com,
linux-kernel@vger.kernel.org, systemtap@sources.redhat.com,
prasanna@in.ibm.com, shaohua.li@intel.com, davem@davemloft.net,
fche@redhat.com
Subject: Re: [PATCH -mm 1/5] list.h: add list_singleton
Date: Sat, 15 Mar 2008 23:36:36 +0100 [thread overview]
Message-ID: <1205620596.6422.8.camel@lappy> (raw)
In-Reply-To: <47DAFAA2.20302@redhat.com>
On Fri, 2008-03-14 at 18:22 -0400, Masami Hiramatsu wrote:
> Andrew Morton wrote:
> > If your usage pattern is:
> >
> > struct foo {
> > ...
> > struct list_head bar_list; /* A list of `struct bar's */
> > };
> >
> > struct bar {
> > struct list_head list; /* Attached to foo.bar_list */
> > ...
> > };
> >
> > then yes, list_singleton() makes sense.
> >
> > But in other usage patterns it does not:
> >
> > struct foo {
> > struct bar *bar_list;
> > ...
> > };
> >
> > struct bar {
> > struct list_head list; /* All the other bars go here */
> > ...
> > };
> >
> > In the second case, emptiness is signified by foo.bar_list==NULL. And in
> > this case, code which does
> >
> > if (foo->bar_list && list_singleton(&foo->bar_list->list))
> >
> > will fail if there is a single item on the list!
> >
> > The second usage pattern is uncommon and list_empty() also returns
> > misleading answers when list_heads are used this way.
>
> I agreed. I assume that list_singleton() is used like as list_empty().
>
>
> > So I guess we can proceed with your list_singleton(), but I'd just like to
> > flag this possible confusion, see what people think..
May I kindly ask to please not use the singleton name like this. It does
not implement the singleton pattern and will be a great confusion for
everybody who expects it to.
next prev parent reply other threads:[~2008-03-15 22:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-14 20:40 [PATCH -mm 1/5] list.h: add list_singleton Masami Hiramatsu
2008-03-14 21:00 ` Andrew Morton
2008-03-14 22:22 ` Masami Hiramatsu
2008-03-15 22:36 ` Peter Zijlstra [this message]
2008-03-17 15:04 ` Masami Hiramatsu
2008-03-17 15:13 ` Peter Zijlstra
2008-03-17 20:52 ` [PATCH -mm] list.h: rename list_singleton to list_is_singular Masami Hiramatsu
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=1205620596.6422.8.camel@lappy \
--to=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=ananth@in.ibm.com \
--cc=davem@davemloft.net \
--cc=fche@redhat.com \
--cc=jkenisto@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@redhat.com \
--cc=prasanna@in.ibm.com \
--cc=shaohua.li@intel.com \
--cc=systemtap@sources.redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.