Bug 192250 - module(9) and its corresponding manpages don't document that evhand (the load/unload/etc handler) can be NULL
Summary: module(9) and its corresponding manpages don't document that evhand (the load...
Status: Closed FIXED
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Guangyuan Yang
URL:
Keywords: easy, patch
Depends on:
Blocks:
 
Reported: 2014-07-29 19:44 UTC by Enji Cooper
Modified: 2021-11-14 06:39 UTC (History)
3 users (show)

See Also:


Attachments
module.9 patch (642 bytes, patch)
2021-09-30 05:21 UTC, Felix Johnson
felix.the.red: maintainer-approval? (felix.the.red)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer freebsd_triage 2014-07-29 19:44:49 UTC
The structure for a kernel module is like so:

 52 /*
 53  * Struct for registering modules statically via SYSINIT.
 54  */
 55 typedef struct moduledata {
 56         const char      *name;          /* module name */
 57         modeventhand_t  evhand;         /* event handler */
 58         void            *priv;          /* extra data */
 59 } moduledata_t;

The documentation doesn't note that evhand can be NULL though (and if it's NULL then modevent_nop will be used in lieu of evhand):

$ grep -r evhand /sys/kern/
/sys/kern/kern_module.c:                    " %d\n", data->name, (void *)data->evhand, data->priv,
/sys/kern/kern_module.c:        newmod->handler = data->evhand ? data->evhand : modevent_nop;
$

I looked at the examples in /usr/share/examples/kld and they didn't provide an example that did this either.
Comment 1 Felix Johnson freebsd_triage 2021-09-30 05:21:32 UTC
Created attachment 228271 [details]
module.9 patch

Mention what happens when the event handler function is NULL.
Comment 2 commit-hook freebsd_committer freebsd_triage 2021-11-11 06:34:09 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=c5e0492ae81e4b0d7946ccfbedb434a9c4071256

commit c5e0492ae81e4b0d7946ccfbedb434a9c4071256
Author:     Felix Johnson <felix.the.red@gmail.com>
AuthorDate: 2021-11-11 06:28:45 +0000
Commit:     Guangyuan Yang <ygy@FreeBSD.org>
CommitDate: 2021-11-11 06:32:54 +0000

    module(9): Document that evhand can be NULL

    PR:             192250
    MFC after:      3 days
    Reported by:    ngie

 share/man/man9/module.9 | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-11-14 06:38:34 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=109330155000bfec215ee39148254d2a0b628798

commit 109330155000bfec215ee39148254d2a0b628798
Author:     Felix Johnson <felix.the.red@gmail.com>
AuthorDate: 2021-11-11 06:28:45 +0000
Commit:     Guangyuan Yang <ygy@FreeBSD.org>
CommitDate: 2021-11-14 06:37:20 +0000

    module(9): Document that evhand can be NULL

    PR:             192250
    Reported by:    ngie

    (cherry picked from commit c5e0492ae81e4b0d7946ccfbedb434a9c4071256)

 share/man/man9/module.9 | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)