summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_extent.c
diff options
context:
space:
mode:
authorart <art@openbsd.org>2002-12-08 04:22:33 +0000
committerart <art@openbsd.org>2002-12-08 04:22:33 +0000
commit2a86633e27bbe2659cd566829a6c3787f8cbf868 (patch)
tree5980f68cb8856819e3e30202c1fe03faa92d4f2b /sys/kern/subr_extent.c
parent - Lock the timeout wheel after the diagnostic checks. (diff)
downloadwireguard-openbsd-2a86633e27bbe2659cd566829a6c3787f8cbf868.tar.xz
wireguard-openbsd-2a86633e27bbe2659cd566829a6c3787f8cbf868.zip
- Use LIST_ macros.
- Make sure that extent_register is not called more than once on an extent.
Diffstat (limited to 'sys/kern/subr_extent.c')
-rw-r--r--sys/kern/subr_extent.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/sys/kern/subr_extent.c b/sys/kern/subr_extent.c
index 7d67a063618..ceac1073ebe 100644
--- a/sys/kern/subr_extent.c
+++ b/sys/kern/subr_extent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_extent.c,v 1.23 2002/06/28 20:45:44 jason Exp $ */
+/* $OpenBSD: subr_extent.c,v 1.24 2002/12/08 04:22:33 art Exp $ */
/* $NetBSD: subr_extent.c,v 1.7 1996/11/21 18:46:34 cgd Exp $ */
/*-
@@ -88,20 +88,27 @@ static void extent_register(struct extent *);
* Should work, no?
*/
static LIST_HEAD(listhead, extent) ext_list;
-static struct listhead *ext_listp;
static void
-extent_register(ex)
- struct extent *ex;
+extent_register(struct extent *ex)
{
- /* Is this redundant? */
- if (ext_listp == NULL){
+ struct extent *ep;
+ static int initialized;
+
+ if (!initialized){
LIST_INIT(&ext_list);
- ext_listp = &ext_list;
+ initialized = 1;
}
+#ifdef DIAGNOSTIC
+ LIST_FOREACH(ep, &ext_list, ex_link) {
+ if (ep == ex)
+ panic("extent_register: already registered");
+ }
+#endif
+
/* Insert into list */
- LIST_INSERT_HEAD(ext_listp, ex, ex_link);
+ LIST_INSERT_HEAD(&ext_list, ex, ex_link);
}
struct pool ex_region_pl;
@@ -131,7 +138,7 @@ extent_find(name)
{
struct extent *ep;
- for(ep = ext_listp->lh_first; ep != NULL; ep = ep->ex_link.le_next){
+ LIST_FOREACH(ep, &ext_list, ex_link) {
if (!strcmp(ep->ex_name, name))
return(ep);
}
@@ -149,7 +156,7 @@ extent_print_all(void)
{
struct extent *ep;
- for(ep = ext_listp->lh_first; ep != NULL; ep = ep->ex_link.le_next){
+ LIST_FOREACH(ep, &ext_list, ex_link) {
extent_print(ep);
}
}