⬢ DragonFlyBSD Kernel Audit
DF-2974 / evt_typo.c
← back to finding ↓ download raw
/*
 * DF-2974: EVENTHANDLER_FAST_DEREGISTER token-paste typo demo.
 *
 * The correct list symbol is Xeventhandler_list_<name> (see
 * DECLARE/DEFINE/INVOKE/REGISTER at sys/sys/eventhandler.h:68/:78/:81/:92).
 * The DEREGISTER macro at :95-96 pastes 'Xeventhandler_list ## name'
 * (no trailing underscore), so ANY use is a compile error.  Everything
 * else in this TU compiles cleanly; the build stops on the macro use.
 */
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/systm.h>
#include <sys/eventhandler.h>

typedef void (*ehf_t)(void *, int);

EVENTHANDLER_FAST_DECLARE(foofam, ehf_t);
EVENTHANDLER_FAST_DEFINE(foofam, ehf_t);

static moduledata_t evt_mod = { "evt_typo", NULL, NULL };
DECLARE_MODULE(evt_typo, evt_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);

int evt_typo_use(void *tag);

int
evt_typo_use(void *tag)
{
	EVENTHANDLER_FAST_REGISTER(foofam, (ehf_t)evt_typo_use, NULL, 0);
	EVENTHANDLER_FAST_DEREGISTER(foofam, tag);	/* <- typo */
	return 0;
}