lkml.org 
[lkml]   [2012]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 05/13] rbtree: performance and correctness test
From
On Tue, Jul 10, 2012 at 5:27 AM, Michal Nazarewicz <mina86@mina86.com> wrote:
> On Tue, 10 Jul 2012 01:35:15 +0200, Michel Lespinasse <walken@google.com> wrote:
>> + u32 prev_key = 0;
>> +
>> + for (rb = rb_first(&root); rb; rb = rb_next(rb)) {
>> + struct test_node *node = rb_entry(rb, struct test_node,
>> rb);
>> + WARN_ON_ONCE(node->key < prev_key);
>
> What if for some reason we generate node with key equal zero or two keys
> with the same value? It may not be the case for current code, but someone
> might change it in the future. I think <= is safer here.

No, it's not illegal for two nodes to have the same key; the second
one to be inserted will just get placed after the first one. The
rbtree library doesn't care either way as it's not even aware of the
key values :)

--
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.


\
 
 \ /
  Last update: 2012-07-11 09:02    [W:0.457 / U:1.184 seconds]
©2003-2014 Jasper Spaans. Advertise on this site