Fix failure case in rb_tree_find_node_leq/geq.

Return NULL, not `NULL - offset'.

XXX pullup to netbsd-5, netbsd-6, netbsd-7
This commit is contained in:
riastradh 2014-08-22 17:17:02 +00:00
parent d0fd8c21fa
commit b4d2027a4b
1 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $ */
/* $NetBSD: rb.c,v 1.12 2014/08/22 17:17:02 riastradh Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -39,10 +39,10 @@
#else
#define KASSERT(s) do { } while (/*CONSTCOND*/ 0)
#endif
__RCSID("$NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $");
__RCSID("$NetBSD: rb.c,v 1.12 2014/08/22 17:17:02 riastradh Exp $");
#else
#include <lib/libkern/libkern.h>
__KERNEL_RCSID(0, "$NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: rb.c,v 1.12 2014/08/22 17:17:02 riastradh Exp $");
#endif
#ifdef _LIBC
@ -145,7 +145,7 @@ rb_tree_find_node_geq(struct rb_tree *rbt, const void *key)
parent = parent->rb_nodes[diff < 0];
}
return RB_NODETOITEM(rbto, last);
return (last == NULL ? NULL : RB_NODETOITEM(rbto, last));
}
void *
@ -166,7 +166,7 @@ rb_tree_find_node_leq(struct rb_tree *rbt, const void *key)
parent = parent->rb_nodes[diff < 0];
}
return RB_NODETOITEM(rbto, last);
return (last == NULL ? NULL : RB_NODETOITEM(rbto, last));
}
void *