From 20cc8c220c17e3f137658d568884c6e882e50d94 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sat, 2 Apr 2016 17:17:19 -0700 Subject: [PATCH] scoutfs: fix next ival busy loop The next interval interface didn't set the ival to return to null when it finds a null next node. The caller would continuously get the same interval. This is what I get for programming late at night, I guess. Signed-off-by: Zach Brown --- kmod/src/ival.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/kmod/src/ival.c b/kmod/src/ival.c index d55e73bd..da111ef8 100644 --- a/kmod/src/ival.c +++ b/kmod/src/ival.c @@ -135,14 +135,13 @@ struct scoutfs_ival *scoutfs_next_ival(struct scoutfs_ival_tree *tree, if (!ival) return first_ival(tree, start, end); - while ((node = rb_next(&ival->node))) { + node = rb_next(&ival->node); + if (node) { ival = container_of(node, struct scoutfs_ival, node); - - if (scoutfs_cmp_key_ranges(start, end, - &ival->start, &ival->end)) - ival = NULL; - break; + if (!scoutfs_cmp_key_ranges(start, end, + &ival->start, &ival->end)) + return ival; } - return ival; + return NULL; }