lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 14 Mar 2008 18:22:26 -0400
From:	Masami Hiramatsu <mhiramat@...hat.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
CC:	ananth@...ibm.com, jkenisto@...ibm.com,
	linux-kernel@...r.kernel.org, systemtap@...rces.redhat.com,
	prasanna@...ibm.com, shaohua.li@...el.com, davem@...emloft.net,
	fche@...hat.com
Subject: Re: [PATCH -mm 1/5] list.h: add list_singleton

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..

Thank you,

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@...hat.com

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ