#include <stdio.h>
#include "globals.h"
-void rb_insert(struct rb_root *root, struct io *iop)
+int rb_insert(struct rb_root *root, struct io *iop)
{
struct io *__iop;
struct rb_node *parent = NULL;
struct rb_node **p = &root->rb_node;
__u64 __s, s = BIT_START(iop);
- ASSERT(root != NULL && iop != NULL);
while (*p) {
parent = *p;
__iop = rb_entry(parent, struct io, rb_node);
else if (s > __s)
p = &(*p)->rb_right;
else
- p = &(*p)->rb_right;
+ return 0;
}
rb_link_node(&iop->rb_node, parent, p);
rb_insert_color(&iop->rb_node, root);
+ return 1;
}
struct io *rb_find_sec(struct rb_root *root, __u64 sec)
return NULL;
}
-void rb_foreach(struct rb_node *n, struct io *iop,
+void rb_foreach(struct rb_node *n, struct io *iop,
void (*fnc)(struct io *iop, struct io *this),
struct list_head *head)
{
if ((iop_s <= this_s) && (this_e <= iop_e)) {
if (fnc) fnc(iop, this);
- if (head) list_add_tail(&this->f_head, head);
+ if (head)
+ list_add_tail(&this->f_head, head);
}
if (iop_s < this_s)
rb_foreach(n->rb_left, iop, fnc, head);