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]
Message-ID: <20090108200243.GD24884@logfs.org>
Date:	Thu, 8 Jan 2009 21:02:43 +0100
From:	Jörn Engel <joern@...fs.org>
To:	Johannes Berg <johannes@...solutions.net>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: [RFC] B+Tree library V2

On Thu, 8 January 2009 18:10:01 +0100, Johannes Berg wrote:
> On Thu, 2009-01-08 at 17:24 +0100, Jörn Engel wrote:
> 
> > If you want to open-code it, you can use btree_lookup_less().  I added
> > that function sometime last month.  Basically something like this:
> > 	key = btree_last(head, geo);
> > 	while (key) {
> > 		/* do something with key */
> > 		key = btree_lookup_less(head, geo, key);
> > 	}
> 
> Ok, so looking deeper into this, how about adding
> 
> #define btree_for_each_key(head, geo, key, tmp)	\
> 	for (key = btree_last(head, geo), tmp = btree_get_prev_key(head, geo, key);
> 	     key; key = tmp, tmp = btree_get_prev_key(head, geo, key))

[ Changed the function name above.  It really isn't a lookup, it returns
a key, not a value.  My fault. ]

Looks correct otherwise.  Probably needs a comment that without "tmp" we
would skip a 0 key.  Or am I the only one who wants to simplify the code
before spotting this little subtlety?

> (and possibly some type-checking variants that hardcode the geo)
> 
> Does that seem correct? And would it be possible to provide btree_last()
> that takes an void ** and fills it with the last entry, and the same for
> lookup_less(), so we can write btree_for_each_entry() too?

Not sure what you mean.  Something with the same effect as this?

#define btree_for_each_val(head, geo, key, val)				\
	 for (key = btree_last(head, geo),				\
	 		val = btree_lookup(head, geo, key);		\
	 		val;						\
			key = btree_get_prev_key(head, geo, key),	\
			val = btree_lookup(head, geo, key))

Jörn

-- 
Time? What's that? Time is only worth what you do with it.
-- Theo de Raadt
--
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