From 79876290818fb97c43165a95f28e16a00c83de4f Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Tue, 17 Dec 2019 03:30:49 +0000 Subject: [PATCH] kbd: const'ify a couple of keyboard_driver fields Nothing modifies these things, but const'ify out of an abundance of caution. If we could const'ify the definition in each keyboard driver, I likely would- improper mutations here can lead to misbehavior or slightly more annoying to debug state. --- sys/dev/kbd/kbdreg.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/dev/kbd/kbdreg.h b/sys/dev/kbd/kbdreg.h index 939da89e0f02..cd489e4c1d80 100644 --- a/sys/dev/kbd/kbdreg.h +++ b/sys/dev/kbd/kbdreg.h @@ -96,12 +96,17 @@ typedef struct keyboard_switch { kbd_diag_t *diag; } keyboard_switch_t; -/* keyboard driver */ +/* + * Keyboard driver definition. Some of these be immutable after definition + * time, e.g. one shouldn't be able to rename a driver or use a different kbdsw + * entirely, but patching individual methods is acceptable. + */ typedef struct keyboard_driver { SLIST_ENTRY(keyboard_driver) link; - char *name; - keyboard_switch_t *kbdsw; - int (*configure)(int); /* backdoor for the console driver */ + const char * const name; + keyboard_switch_t * const kbdsw; + /* backdoor for the console driver */ + int (* const configure)(int); } keyboard_driver_t; /* keyboard */