Module Name: src Committed By: matt Date: Tue Jan 18 08:16:43 UTC 2011
Modified Files: src/sys/kern: subr_evcnt.c Log Message: Add code to detect attaching of evcnt before evcnt has been initialized. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/kern/subr_evcnt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/subr_evcnt.c diff -u src/sys/kern/subr_evcnt.c:1.7 src/sys/kern/subr_evcnt.c:1.8 --- src/sys/kern/subr_evcnt.c:1.7 Sat Dec 11 22:30:54 2010 +++ src/sys/kern/subr_evcnt.c Tue Jan 18 08:16:43 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_evcnt.c,v 1.7 2010/12/11 22:30:54 matt Exp $ */ +/* $NetBSD: subr_evcnt.c,v 1.8 2011/01/18 08:16:43 matt Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_evcnt.c,v 1.7 2010/12/11 22:30:54 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_evcnt.c,v 1.8 2011/01/18 08:16:43 matt Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -87,6 +87,7 @@ /* list of all events */ struct evcntlist allevents = TAILQ_HEAD_INITIALIZER(allevents); static kmutex_t evmtx; +static bool init_done; /* * We need a dummy object to stuff into the evcnt link set to @@ -105,8 +106,12 @@ __link_set_decl(evcnts, struct evcnt); struct evcnt * const *evp; + KASSERT(!init_done); + mutex_init(&evmtx, MUTEX_DEFAULT, IPL_NONE); + init_done = true; + __link_set_foreach(evp, evcnts) { if (*evp == &dummy_static_evcnt) continue; @@ -123,6 +128,10 @@ { int len; + KASSERTMSG(init_done, + ("%s: evcnt non initialized: group=<%s> name=<%s>", + __func__, ev->ev_group, ev->ev_name)); + len = strlen(ev->ev_group); #ifdef DIAGNOSTIC if (len >= EVCNT_STRING_MAX) /* ..._MAX includes NUL */